| author | haftmann | 
| Wed, 05 Apr 2017 13:47:40 +0200 | |
| changeset 65389 | 6f9c6ae27984 | 
| parent 64786 | 340db65fd2c1 | 
| child 65396 | b42167902f57 | 
| permissions | -rw-r--r-- | 
| 41959 | 1 | (* Title: HOL/Library/Formal_Power_Series.thy | 
| 29687 | 2 | Author: Amine Chaieb, University of Cambridge | 
| 3 | *) | |
| 4 | ||
| 60501 | 5 | section \<open>A formalization of formal power series\<close> | 
| 29687 | 6 | |
| 7 | theory Formal_Power_Series | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 8 | imports Complex_Main "~~/src/HOL/Number_Theory/Euclidean_Algorithm" | 
| 29687 | 9 | begin | 
| 10 | ||
| 60501 | 11 | |
| 60500 | 12 | subsection \<open>The type of formal power series\<close> | 
| 29687 | 13 | |
| 49834 | 14 | typedef 'a fps = "{f :: nat \<Rightarrow> 'a. True}"
 | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 15 | morphisms fps_nth Abs_fps | 
| 29687 | 16 | by simp | 
| 17 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 18 | notation fps_nth (infixl "$" 75) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 19 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 20 | lemma expand_fps_eq: "p = q \<longleftrightarrow> (\<forall>n. p $ n = q $ n)" | 
| 39302 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 nipkow parents: 
39198diff
changeset | 21 | by (simp add: fps_nth_inject [symmetric] fun_eq_iff) | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 22 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 23 | lemma fps_ext: "(\<And>n. p $ n = q $ n) \<Longrightarrow> p = q" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 24 | by (simp add: expand_fps_eq) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 25 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 26 | lemma fps_nth_Abs_fps [simp]: "Abs_fps f $ n = f n" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 27 | by (simp add: Abs_fps_inverse) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 28 | |
| 60501 | 29 | text \<open>Definition of the basic elements 0 and 1 and the basic operations of addition, | 
| 30 | negation and multiplication.\<close> | |
| 29687 | 31 | |
| 36409 | 32 | instantiation fps :: (zero) zero | 
| 29687 | 33 | begin | 
| 60501 | 34 | definition fps_zero_def: "0 = Abs_fps (\<lambda>n. 0)" | 
| 35 | instance .. | |
| 29687 | 36 | end | 
| 37 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 38 | lemma fps_zero_nth [simp]: "0 $ n = 0" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 39 | unfolding fps_zero_def by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 40 | |
| 36409 | 41 | instantiation fps :: ("{one, zero}") one
 | 
| 29687 | 42 | begin | 
| 60501 | 43 | definition fps_one_def: "1 = Abs_fps (\<lambda>n. if n = 0 then 1 else 0)" | 
| 44 | instance .. | |
| 29687 | 45 | end | 
| 46 | ||
| 30488 | 47 | lemma fps_one_nth [simp]: "1 $ n = (if n = 0 then 1 else 0)" | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 48 | unfolding fps_one_def by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 49 | |
| 54681 | 50 | instantiation fps :: (plus) plus | 
| 29687 | 51 | begin | 
| 60501 | 52 | definition fps_plus_def: "op + = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n + g $ n))" | 
| 53 | instance .. | |
| 29687 | 54 | end | 
| 55 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 56 | lemma fps_add_nth [simp]: "(f + g) $ n = f $ n + g $ n" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 57 | unfolding fps_plus_def by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 58 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 59 | instantiation fps :: (minus) minus | 
| 29687 | 60 | begin | 
| 60501 | 61 | definition fps_minus_def: "op - = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n - g $ n))" | 
| 62 | instance .. | |
| 29687 | 63 | end | 
| 64 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 65 | lemma fps_sub_nth [simp]: "(f - g) $ n = f $ n - g $ n" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 66 | unfolding fps_minus_def by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 67 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 68 | instantiation fps :: (uminus) uminus | 
| 29687 | 69 | begin | 
| 60501 | 70 | definition fps_uminus_def: "uminus = (\<lambda>f. Abs_fps (\<lambda>n. - (f $ n)))" | 
| 71 | instance .. | |
| 29687 | 72 | end | 
| 73 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 74 | lemma fps_neg_nth [simp]: "(- f) $ n = - (f $ n)" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 75 | unfolding fps_uminus_def by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 76 | |
| 54681 | 77 | instantiation fps :: ("{comm_monoid_add, times}") times
 | 
| 29687 | 78 | begin | 
| 60501 | 79 | definition fps_times_def: "op * = (\<lambda>f g. Abs_fps (\<lambda>n. \<Sum>i=0..n. f $ i * g $ (n - i)))" | 
| 80 | instance .. | |
| 29687 | 81 | end | 
| 82 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 83 | lemma fps_mult_nth: "(f * g) $ n = (\<Sum>i=0..n. f$i * g$(n - i))" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 84 | unfolding fps_times_def by simp | 
| 29687 | 85 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 86 | lemma fps_mult_nth_0 [simp]: "(f * g) $ 0 = f $ 0 * g $ 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 87 | unfolding fps_times_def by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 88 | |
| 52891 | 89 | declare atLeastAtMost_iff [presburger] | 
| 90 | declare Bex_def [presburger] | |
| 91 | declare Ball_def [presburger] | |
| 29687 | 92 | |
| 29913 | 93 | lemma mult_delta_left: | 
| 94 | fixes x y :: "'a::mult_zero" | |
| 95 | shows "(if b then x else 0) * y = (if b then x * y else 0)" | |
| 96 | by simp | |
| 97 | ||
| 98 | lemma mult_delta_right: | |
| 99 | fixes x y :: "'a::mult_zero" | |
| 100 | shows "x * (if b then y else 0) = (if b then x * y else 0)" | |
| 101 | by simp | |
| 102 | ||
| 29687 | 103 | lemma cond_value_iff: "f (if b then x else y) = (if b then f x else f y)" | 
| 104 | by auto | |
| 52891 | 105 | |
| 29687 | 106 | lemma cond_application_beta: "(if b then f else g) x = (if b then f x else g x)" | 
| 107 | by auto | |
| 108 | ||
| 60501 | 109 | |
| 110 | subsection \<open>Formal power series form a commutative ring with unity, if the range of sequences | |
| 60500 | 111 | they represent is a commutative ring with unity\<close> | 
| 29687 | 112 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 113 | instance fps :: (semigroup_add) semigroup_add | 
| 29687 | 114 | proof | 
| 52891 | 115 | fix a b c :: "'a fps" | 
| 116 | show "a + b + c = a + (b + c)" | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 117 | by (simp add: fps_ext add.assoc) | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 118 | qed | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 119 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 120 | instance fps :: (ab_semigroup_add) ab_semigroup_add | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 121 | proof | 
| 52891 | 122 | fix a b :: "'a fps" | 
| 123 | show "a + b = b + a" | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 124 | by (simp add: fps_ext add.commute) | 
| 29687 | 125 | qed | 
| 126 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 127 | lemma fps_mult_assoc_lemma: | 
| 53195 | 128 | fixes k :: nat | 
| 129 | and f :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> 'a::comm_monoid_add" | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 130 | shows "(\<Sum>j=0..k. \<Sum>i=0..j. f i (j - i) (n - j)) = | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 131 | (\<Sum>j=0..k. \<Sum>i=0..k - j. f j i (n - j - i))" | 
| 64267 | 132 | by (induct k) (simp_all add: Suc_diff_le sum.distrib add.assoc) | 
| 29687 | 133 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 134 | instance fps :: (semiring_0) semigroup_mult | 
| 29687 | 135 | proof | 
| 136 | fix a b c :: "'a fps" | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 137 | show "(a * b) * c = a * (b * c)" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 138 | proof (rule fps_ext) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 139 | fix n :: nat | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 140 | have "(\<Sum>j=0..n. \<Sum>i=0..j. a$i * b$(j - i) * c$(n - j)) = | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 141 | (\<Sum>j=0..n. \<Sum>i=0..n - j. a$j * b$i * c$(n - j - i))" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 142 | by (rule fps_mult_assoc_lemma) | 
| 52891 | 143 | then show "((a * b) * c) $ n = (a * (b * c)) $ n" | 
| 64267 | 144 | by (simp add: fps_mult_nth sum_distrib_left sum_distrib_right mult.assoc) | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 145 | qed | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 146 | qed | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 147 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 148 | lemma fps_mult_commute_lemma: | 
| 52903 | 149 | fixes n :: nat | 
| 150 | and f :: "nat \<Rightarrow> nat \<Rightarrow> 'a::comm_monoid_add" | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 151 | shows "(\<Sum>i=0..n. f i (n - i)) = (\<Sum>i=0..n. f (n - i) i)" | 
| 64267 | 152 | by (rule sum.reindex_bij_witness[where i="op - n" and j="op - n"]) auto | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 153 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 154 | instance fps :: (comm_semiring_0) ab_semigroup_mult | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 155 | proof | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 156 | fix a b :: "'a fps" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 157 | show "a * b = b * a" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 158 | proof (rule fps_ext) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 159 | fix n :: nat | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 160 | have "(\<Sum>i=0..n. a$i * b$(n - i)) = (\<Sum>i=0..n. a$(n - i) * b$i)" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 161 | by (rule fps_mult_commute_lemma) | 
| 52891 | 162 | then show "(a * b) $ n = (b * a) $ n" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 163 | by (simp add: fps_mult_nth mult.commute) | 
| 29687 | 164 | qed | 
| 165 | qed | |
| 166 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 167 | instance fps :: (monoid_add) monoid_add | 
| 29687 | 168 | proof | 
| 52891 | 169 | fix a :: "'a fps" | 
| 170 | show "0 + a = a" by (simp add: fps_ext) | |
| 171 | show "a + 0 = a" by (simp add: fps_ext) | |
| 29687 | 172 | qed | 
| 173 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 174 | instance fps :: (comm_monoid_add) comm_monoid_add | 
| 29687 | 175 | proof | 
| 52891 | 176 | fix a :: "'a fps" | 
| 177 | show "0 + a = a" by (simp add: fps_ext) | |
| 29687 | 178 | qed | 
| 179 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 180 | instance fps :: (semiring_1) monoid_mult | 
| 29687 | 181 | proof | 
| 52891 | 182 | fix a :: "'a fps" | 
| 60501 | 183 | show "1 * a = a" | 
| 64267 | 184 | by (simp add: fps_ext fps_mult_nth mult_delta_left sum.delta) | 
| 60501 | 185 | show "a * 1 = a" | 
| 64267 | 186 | by (simp add: fps_ext fps_mult_nth mult_delta_right sum.delta') | 
| 29687 | 187 | qed | 
| 188 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 189 | instance fps :: (cancel_semigroup_add) cancel_semigroup_add | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 190 | proof | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 191 | fix a b c :: "'a fps" | 
| 60501 | 192 | show "b = c" if "a + b = a + c" | 
| 193 | using that by (simp add: expand_fps_eq) | |
| 194 | show "b = c" if "b + a = c + a" | |
| 195 | using that by (simp add: expand_fps_eq) | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 196 | qed | 
| 29687 | 197 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 198 | instance fps :: (cancel_ab_semigroup_add) cancel_ab_semigroup_add | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 199 | proof | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 200 | fix a b c :: "'a fps" | 
| 60501 | 201 | show "a + b - a = b" | 
| 202 | by (simp add: expand_fps_eq) | |
| 203 | show "a - b - c = a - (b + c)" | |
| 204 | by (simp add: expand_fps_eq diff_diff_eq) | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 205 | qed | 
| 29687 | 206 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 207 | instance fps :: (cancel_comm_monoid_add) cancel_comm_monoid_add .. | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 208 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 209 | instance fps :: (group_add) group_add | 
| 29687 | 210 | proof | 
| 52891 | 211 | fix a b :: "'a fps" | 
| 212 | show "- a + a = 0" by (simp add: fps_ext) | |
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53374diff
changeset | 213 | show "a + - b = a - b" by (simp add: fps_ext) | 
| 29687 | 214 | qed | 
| 215 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 216 | instance fps :: (ab_group_add) ab_group_add | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 217 | proof | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 218 | fix a b :: "'a fps" | 
| 52891 | 219 | show "- a + a = 0" by (simp add: fps_ext) | 
| 220 | show "a - b = a + - b" by (simp add: fps_ext) | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 221 | qed | 
| 29687 | 222 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 223 | instance fps :: (zero_neq_one) zero_neq_one | 
| 60679 | 224 | by standard (simp add: expand_fps_eq) | 
| 29687 | 225 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 226 | instance fps :: (semiring_0) semiring | 
| 29687 | 227 | proof | 
| 228 | fix a b c :: "'a fps" | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 229 | show "(a + b) * c = a * c + b * c" | 
| 64267 | 230 | by (simp add: expand_fps_eq fps_mult_nth distrib_right sum.distrib) | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 231 | show "a * (b + c) = a * b + a * c" | 
| 64267 | 232 | by (simp add: expand_fps_eq fps_mult_nth distrib_left sum.distrib) | 
| 29687 | 233 | qed | 
| 234 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 235 | instance fps :: (semiring_0) semiring_0 | 
| 29687 | 236 | proof | 
| 53195 | 237 | fix a :: "'a fps" | 
| 60501 | 238 | show "0 * a = 0" | 
| 239 | by (simp add: fps_ext fps_mult_nth) | |
| 240 | show "a * 0 = 0" | |
| 241 | by (simp add: fps_ext fps_mult_nth) | |
| 29687 | 242 | qed | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 243 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 244 | instance fps :: (semiring_0_cancel) semiring_0_cancel .. | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 245 | |
| 60867 | 246 | instance fps :: (semiring_1) semiring_1 .. | 
| 247 | ||
| 60501 | 248 | |
| 60500 | 249 | subsection \<open>Selection of the nth power of the implicit variable in the infinite sum\<close> | 
| 29687 | 250 | |
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 251 | lemma fps_square_nth: "(f^2) $ n = (\<Sum>k\<le>n. f $ k * f $ (n - k))" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 252 | by (simp add: power2_eq_square fps_mult_nth atLeast0AtMost) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 253 | |
| 29687 | 254 | lemma fps_nonzero_nth: "f \<noteq> 0 \<longleftrightarrow> (\<exists> n. f $n \<noteq> 0)" | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 255 | by (simp add: expand_fps_eq) | 
| 29687 | 256 | |
| 52902 | 257 | lemma fps_nonzero_nth_minimal: "f \<noteq> 0 \<longleftrightarrow> (\<exists>n. f $ n \<noteq> 0 \<and> (\<forall>m < n. f $ m = 0))" | 
| 60501 | 258 | (is "?lhs \<longleftrightarrow> ?rhs") | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 259 | proof | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 260 | let ?n = "LEAST n. f $ n \<noteq> 0" | 
| 60501 | 261 | show ?rhs if ?lhs | 
| 262 | proof - | |
| 263 | from that have "\<exists>n. f $ n \<noteq> 0" | |
| 264 | by (simp add: fps_nonzero_nth) | |
| 265 | then have "f $ ?n \<noteq> 0" | |
| 266 | by (rule LeastI_ex) | |
| 267 | moreover have "\<forall>m<?n. f $ m = 0" | |
| 268 | by (auto dest: not_less_Least) | |
| 269 | ultimately have "f $ ?n \<noteq> 0 \<and> (\<forall>m<?n. f $ m = 0)" .. | |
| 270 | then show ?thesis .. | |
| 271 | qed | |
| 272 | show ?lhs if ?rhs | |
| 273 | using that by (auto simp add: expand_fps_eq) | |
| 29687 | 274 | qed | 
| 275 | ||
| 276 | lemma fps_eq_iff: "f = g \<longleftrightarrow> (\<forall>n. f $ n = g $n)" | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 277 | by (rule expand_fps_eq) | 
| 29687 | 278 | |
| 64267 | 279 | lemma fps_sum_nth: "sum f S $ n = sum (\<lambda>k. (f k) $ n) S" | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 280 | proof (cases "finite S") | 
| 52891 | 281 | case True | 
| 282 | then show ?thesis by (induct set: finite) auto | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 283 | next | 
| 52891 | 284 | case False | 
| 285 | then show ?thesis by simp | |
| 29687 | 286 | qed | 
| 287 | ||
| 60501 | 288 | |
| 289 | subsection \<open>Injection of the basic ring elements and multiplication by scalars\<close> | |
| 29687 | 290 | |
| 52891 | 291 | definition "fps_const c = Abs_fps (\<lambda>n. if n = 0 then c else 0)" | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 292 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 293 | lemma fps_nth_fps_const [simp]: "fps_const c $ n = (if n = 0 then c else 0)" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 294 | unfolding fps_const_def by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 295 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 296 | lemma fps_const_0_eq_0 [simp]: "fps_const 0 = 0" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 297 | by (simp add: fps_ext) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 298 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 299 | lemma fps_const_1_eq_1 [simp]: "fps_const 1 = 1" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 300 | by (simp add: fps_ext) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 301 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 302 | lemma fps_const_neg [simp]: "- (fps_const (c::'a::ring)) = fps_const (- c)" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 303 | by (simp add: fps_ext) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 304 | |
| 54681 | 305 | lemma fps_const_add [simp]: "fps_const (c::'a::monoid_add) + fps_const d = fps_const (c + d)" | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 306 | by (simp add: fps_ext) | 
| 52891 | 307 | |
| 54681 | 308 | lemma fps_const_sub [simp]: "fps_const (c::'a::group_add) - fps_const d = fps_const (c - d)" | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 309 | by (simp add: fps_ext) | 
| 52891 | 310 | |
| 54681 | 311 | lemma fps_const_mult[simp]: "fps_const (c::'a::ring) * fps_const d = fps_const (c * d)" | 
| 64267 | 312 | by (simp add: fps_eq_iff fps_mult_nth sum.neutral) | 
| 29687 | 313 | |
| 54681 | 314 | lemma fps_const_add_left: "fps_const (c::'a::monoid_add) + f = | 
| 48757 | 315 | Abs_fps (\<lambda>n. if n = 0 then c + f$0 else f$n)" | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 316 | by (simp add: fps_ext) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 317 | |
| 54681 | 318 | lemma fps_const_add_right: "f + fps_const (c::'a::monoid_add) = | 
| 48757 | 319 | Abs_fps (\<lambda>n. if n = 0 then f$0 + c else f$n)" | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 320 | by (simp add: fps_ext) | 
| 29687 | 321 | |
| 54681 | 322 | lemma fps_const_mult_left: "fps_const (c::'a::semiring_0) * f = Abs_fps (\<lambda>n. c * f$n)" | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 323 | unfolding fps_eq_iff fps_mult_nth | 
| 64267 | 324 | by (simp add: fps_const_def mult_delta_left sum.delta) | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 325 | |
| 54681 | 326 | lemma fps_const_mult_right: "f * fps_const (c::'a::semiring_0) = Abs_fps (\<lambda>n. f$n * c)" | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 327 | unfolding fps_eq_iff fps_mult_nth | 
| 64267 | 328 | by (simp add: fps_const_def mult_delta_right sum.delta') | 
| 29687 | 329 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 330 | lemma fps_mult_left_const_nth [simp]: "(fps_const (c::'a::semiring_1) * f)$n = c* f$n" | 
| 64267 | 331 | by (simp add: fps_mult_nth mult_delta_left sum.delta) | 
| 29687 | 332 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 333 | lemma fps_mult_right_const_nth [simp]: "(f * fps_const (c::'a::semiring_1))$n = f$n * c" | 
| 64267 | 334 | by (simp add: fps_mult_nth mult_delta_right sum.delta') | 
| 29687 | 335 | |
| 60501 | 336 | |
| 60500 | 337 | subsection \<open>Formal power series form an integral domain\<close> | 
| 29687 | 338 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 339 | instance fps :: (ring) ring .. | 
| 29687 | 340 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 341 | instance fps :: (ring_1) ring_1 | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53374diff
changeset | 342 | by (intro_classes, auto simp add: distrib_right) | 
| 29687 | 343 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 344 | instance fps :: (comm_ring_1) comm_ring_1 | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53374diff
changeset | 345 | by (intro_classes, auto simp add: distrib_right) | 
| 29687 | 346 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 347 | instance fps :: (ring_no_zero_divisors) ring_no_zero_divisors | 
| 29687 | 348 | proof | 
| 349 | fix a b :: "'a fps" | |
| 60501 | 350 | assume "a \<noteq> 0" and "b \<noteq> 0" | 
| 351 | then obtain i j where i: "a $ i \<noteq> 0" "\<forall>k<i. a $ k = 0" and j: "b $ j \<noteq> 0" "\<forall>k<j. b $ k =0" | |
| 54681 | 352 | unfolding fps_nonzero_nth_minimal | 
| 29687 | 353 | by blast+ | 
| 60501 | 354 | have "(a * b) $ (i + j) = (\<Sum>k=0..i+j. a $ k * b $ (i + j - k))" | 
| 29687 | 355 | by (rule fps_mult_nth) | 
| 60501 | 356 |   also have "\<dots> = (a $ i * b $ (i + j - i)) + (\<Sum>k\<in>{0..i+j} - {i}. a $ k * b $ (i + j - k))"
 | 
| 64267 | 357 | by (rule sum.remove) simp_all | 
| 60501 | 358 |   also have "(\<Sum>k\<in>{0..i+j}-{i}. a $ k * b $ (i + j - k)) = 0"
 | 
| 64267 | 359 | proof (rule sum.neutral [rule_format]) | 
| 60501 | 360 |     fix k assume "k \<in> {0..i+j} - {i}"
 | 
| 361 | then have "k < i \<or> i+j-k < j" | |
| 362 | by auto | |
| 363 | then show "a $ k * b $ (i + j - k) = 0" | |
| 364 | using i j by auto | |
| 365 | qed | |
| 366 | also have "a $ i * b $ (i + j - i) + 0 = a $ i * b $ j" | |
| 367 | by simp | |
| 368 | also have "a $ i * b $ j \<noteq> 0" | |
| 369 | using i j by simp | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 370 | finally have "(a*b) $ (i+j) \<noteq> 0" . | 
| 60501 | 371 | then show "a * b \<noteq> 0" | 
| 372 | unfolding fps_nonzero_nth by blast | |
| 29687 | 373 | qed | 
| 374 | ||
| 36311 
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
 haftmann parents: 
36309diff
changeset | 375 | instance fps :: (ring_1_no_zero_divisors) ring_1_no_zero_divisors .. | 
| 
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
 haftmann parents: 
36309diff
changeset | 376 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 377 | instance fps :: (idom) idom .. | 
| 29687 | 378 | |
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 379 | lemma numeral_fps_const: "numeral k = fps_const (numeral k)" | 
| 48757 | 380 | by (induct k) (simp_all only: numeral.simps fps_const_1_eq_1 | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 381 | fps_const_add [symmetric]) | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 382 | |
| 60867 | 383 | lemma neg_numeral_fps_const: | 
| 384 | "(- numeral k :: 'a :: ring_1 fps) = fps_const (- numeral k)" | |
| 385 | by (simp add: numeral_fps_const) | |
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 386 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 387 | lemma fps_numeral_nth: "numeral n $ i = (if i = 0 then numeral n else 0)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 388 | by (simp add: numeral_fps_const) | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 389 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 390 | lemma fps_numeral_nth_0 [simp]: "numeral n $ 0 = numeral n" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 391 | by (simp add: numeral_fps_const) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 392 | |
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 393 | lemma fps_of_nat: "fps_const (of_nat c) = of_nat c" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 394 | by (induction c) (simp_all add: fps_const_add [symmetric] del: fps_const_add) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 395 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 396 | |
| 60501 | 397 | |
| 398 | subsection \<open>The eXtractor series X\<close> | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 399 | |
| 54681 | 400 | lemma minus_one_power_iff: "(- (1::'a::comm_ring_1)) ^ n = (if even n then 1 else - 1)" | 
| 48757 | 401 | by (induct n) auto | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 402 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 403 | definition "X = Abs_fps (\<lambda>n. if n = 1 then 1 else 0)" | 
| 53195 | 404 | |
| 405 | lemma X_mult_nth [simp]: | |
| 54681 | 406 | "(X * (f :: 'a::semiring_1 fps)) $n = (if n = 0 then 0 else f $ (n - 1))" | 
| 53195 | 407 | proof (cases "n = 0") | 
| 408 | case False | |
| 409 | have "(X * f) $n = (\<Sum>i = 0..n. X $ i * f $ (n - i))" | |
| 410 | by (simp add: fps_mult_nth) | |
| 411 | also have "\<dots> = f $ (n - 1)" | |
| 64267 | 412 | using False by (simp add: X_def mult_delta_left sum.delta) | 
| 60501 | 413 | finally show ?thesis | 
| 414 | using False by simp | |
| 53195 | 415 | next | 
| 416 | case True | |
| 60501 | 417 | then show ?thesis | 
| 418 | by (simp add: fps_mult_nth X_def) | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 419 | qed | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 420 | |
| 48757 | 421 | lemma X_mult_right_nth[simp]: | 
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 422 | "((a::'a::semiring_1 fps) * X) $ n = (if n = 0 then 0 else a $ (n - 1))" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 423 | proof - | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 424 | have "(a * X) $ n = (\<Sum>i = 0..n. a $ i * (if n - i = Suc 0 then 1 else 0))" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 425 | by (simp add: fps_times_def X_def) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 426 | also have "\<dots> = (\<Sum>i = 0..n. if i = n - 1 then if n = 0 then 0 else a $ i else 0)" | 
| 64267 | 427 | by (intro sum.cong) auto | 
| 428 | also have "\<dots> = (if n = 0 then 0 else a $ (n - 1))" by (simp add: sum.delta) | |
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 429 | finally show ?thesis . | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 430 | qed | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 431 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 432 | lemma fps_mult_X_commute: "X * (a :: 'a :: semiring_1 fps) = a * X" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 433 | by (simp add: fps_eq_iff) | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 434 | |
| 54681 | 435 | lemma X_power_iff: "X^k = Abs_fps (\<lambda>n. if n = k then 1::'a::comm_ring_1 else 0)" | 
| 52902 | 436 | proof (induct k) | 
| 437 | case 0 | |
| 54452 | 438 | then show ?case by (simp add: X_def fps_eq_iff) | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 439 | next | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 440 | case (Suc k) | 
| 60501 | 441 | have "(X^Suc k) $ m = (if m = Suc k then 1::'a else 0)" for m | 
| 442 | proof - | |
| 443 | have "(X^Suc k) $ m = (if m = 0 then 0 else (X^k) $ (m - 1))" | |
| 52891 | 444 | by (simp del: One_nat_def) | 
| 60501 | 445 | then show ?thesis | 
| 52891 | 446 | using Suc.hyps by (auto cong del: if_weak_cong) | 
| 60501 | 447 | qed | 
| 448 | then show ?case | |
| 449 | by (simp add: fps_eq_iff) | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 450 | qed | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 451 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 452 | lemma X_nth[simp]: "X$n = (if n = 1 then 1 else 0)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 453 | by (simp add: X_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 454 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 455 | lemma X_power_nth[simp]: "(X^k) $n = (if n = k then 1 else 0::'a::comm_ring_1)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 456 | by (simp add: X_power_iff) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 457 | |
| 60501 | 458 | lemma X_power_mult_nth: "(X^k * (f :: 'a::comm_ring_1 fps)) $n = (if n < k then 0 else f $ (n - k))" | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 459 | apply (induct k arbitrary: n) | 
| 52891 | 460 | apply simp | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 461 | unfolding power_Suc mult.assoc | 
| 48757 | 462 | apply (case_tac n) | 
| 463 | apply auto | |
| 464 | done | |
| 465 | ||
| 466 | lemma X_power_mult_right_nth: | |
| 54681 | 467 | "((f :: 'a::comm_ring_1 fps) * X^k) $n = (if n < k then 0 else f $ (n - k))" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 468 | by (metis X_power_mult_nth mult.commute) | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 469 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 470 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 471 | lemma X_neq_fps_const [simp]: "(X :: 'a :: zero_neq_one fps) \<noteq> fps_const c" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 472 | proof | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 473 | assume "(X::'a fps) = fps_const (c::'a)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 474 | hence "X$1 = (fps_const (c::'a))$1" by (simp only:) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 475 | thus False by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 476 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 477 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 478 | lemma X_neq_zero [simp]: "(X :: 'a :: zero_neq_one fps) \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 479 | by (simp only: fps_const_0_eq_0[symmetric] X_neq_fps_const) simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 480 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 481 | lemma X_neq_one [simp]: "(X :: 'a :: zero_neq_one fps) \<noteq> 1" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 482 | by (simp only: fps_const_1_eq_1[symmetric] X_neq_fps_const) simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 483 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 484 | lemma X_neq_numeral [simp]: "(X :: 'a :: {semiring_1,zero_neq_one} fps) \<noteq> numeral c"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 485 | by (simp only: numeral_fps_const X_neq_fps_const) simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 486 | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 487 | lemma X_pow_eq_X_pow_iff [simp]: | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 488 |   "(X :: ('a :: {comm_ring_1}) fps) ^ m = X ^ n \<longleftrightarrow> m = n"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 489 | proof | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 490 | assume "(X :: 'a fps) ^ m = X ^ n" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 491 | hence "(X :: 'a fps) ^ m $ m = X ^ n $ m" by (simp only:) | 
| 62390 | 492 | thus "m = n" by (simp split: if_split_asm) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 493 | qed simp_all | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 494 | |
| 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 495 | |
| 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 496 | subsection \<open>Subdegrees\<close> | 
| 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 497 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 498 | definition subdegree :: "('a::zero) fps \<Rightarrow> nat" where
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 499 | "subdegree f = (if f = 0 then 0 else LEAST n. f$n \<noteq> 0)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 500 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 501 | lemma subdegreeI: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 502 | assumes "f $ d \<noteq> 0" and "\<And>i. i < d \<Longrightarrow> f $ i = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 503 | shows "subdegree f = d" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 504 | proof- | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 505 | from assms(1) have "f \<noteq> 0" by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 506 | moreover from assms(1) have "(LEAST i. f $ i \<noteq> 0) = d" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 507 | proof (rule Least_equality) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 508 | fix e assume "f $ e \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 509 | with assms(2) have "\<not>(e < d)" by blast | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 510 | thus "e \<ge> d" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 511 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 512 | ultimately show ?thesis unfolding subdegree_def by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 513 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 514 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 515 | lemma nth_subdegree_nonzero [simp,intro]: "f \<noteq> 0 \<Longrightarrow> f $ subdegree f \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 516 | proof- | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 517 | assume "f \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 518 | hence "subdegree f = (LEAST n. f $ n \<noteq> 0)" by (simp add: subdegree_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 519 | also from \<open>f \<noteq> 0\<close> have "\<exists>n. f$n \<noteq> 0" using fps_nonzero_nth by blast | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 520 | from LeastI_ex[OF this] have "f $ (LEAST n. f $ n \<noteq> 0) \<noteq> 0" . | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 521 | finally show ?thesis . | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 522 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 523 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 524 | lemma nth_less_subdegree_zero [dest]: "n < subdegree f \<Longrightarrow> f $ n = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 525 | proof (cases "f = 0") | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 526 | assume "f \<noteq> 0" and less: "n < subdegree f" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 527 | note less | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 528 | also from \<open>f \<noteq> 0\<close> have "subdegree f = (LEAST n. f $ n \<noteq> 0)" by (simp add: subdegree_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 529 | finally show "f $ n = 0" using not_less_Least by blast | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 530 | qed simp_all | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 531 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 532 | lemma subdegree_geI: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 533 | assumes "f \<noteq> 0" "\<And>i. i < n \<Longrightarrow> f$i = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 534 | shows "subdegree f \<ge> n" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 535 | proof (rule ccontr) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 536 | assume "\<not>(subdegree f \<ge> n)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 537 | with assms(2) have "f $ subdegree f = 0" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 538 | moreover from assms(1) have "f $ subdegree f \<noteq> 0" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 539 | ultimately show False by contradiction | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 540 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 541 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 542 | lemma subdegree_greaterI: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 543 | assumes "f \<noteq> 0" "\<And>i. i \<le> n \<Longrightarrow> f$i = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 544 | shows "subdegree f > n" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 545 | proof (rule ccontr) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 546 | assume "\<not>(subdegree f > n)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 547 | with assms(2) have "f $ subdegree f = 0" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 548 | moreover from assms(1) have "f $ subdegree f \<noteq> 0" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 549 | ultimately show False by contradiction | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 550 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 551 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 552 | lemma subdegree_leI: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 553 | "f $ n \<noteq> 0 \<Longrightarrow> subdegree f \<le> n" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 554 | by (rule leI) auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 555 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 556 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 557 | lemma subdegree_0 [simp]: "subdegree 0 = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 558 | by (simp add: subdegree_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 559 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 560 | lemma subdegree_1 [simp]: "subdegree (1 :: ('a :: zero_neq_one) fps) = 0"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 561 | by (auto intro!: subdegreeI) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 562 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 563 | lemma subdegree_X [simp]: "subdegree (X :: ('a :: zero_neq_one) fps) = 1"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 564 | by (auto intro!: subdegreeI simp: X_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 565 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 566 | lemma subdegree_fps_const [simp]: "subdegree (fps_const c) = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 567 | by (cases "c = 0") (auto intro!: subdegreeI) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 568 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 569 | lemma subdegree_numeral [simp]: "subdegree (numeral n) = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 570 | by (simp add: numeral_fps_const) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 571 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 572 | lemma subdegree_eq_0_iff: "subdegree f = 0 \<longleftrightarrow> f = 0 \<or> f $ 0 \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 573 | proof (cases "f = 0") | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 574 | assume "f \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 575 | thus ?thesis | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 576 | using nth_subdegree_nonzero[OF \<open>f \<noteq> 0\<close>] by (fastforce intro!: subdegreeI) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 577 | qed simp_all | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 578 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 579 | lemma subdegree_eq_0 [simp]: "f $ 0 \<noteq> 0 \<Longrightarrow> subdegree f = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 580 | by (simp add: subdegree_eq_0_iff) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 581 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 582 | lemma nth_subdegree_mult [simp]: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 583 |   fixes f g :: "('a :: {mult_zero,comm_monoid_add}) fps"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 584 | shows "(f * g) $ (subdegree f + subdegree g) = f $ subdegree f * g $ subdegree g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 585 | proof- | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 586 | let ?n = "subdegree f + subdegree g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 587 | have "(f * g) $ ?n = (\<Sum>i=0..?n. f$i * g$(?n-i))" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 588 | by (simp add: fps_mult_nth) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 589 | also have "... = (\<Sum>i=0..?n. if i = subdegree f then f$i * g$(?n-i) else 0)" | 
| 64267 | 590 | proof (intro sum.cong) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 591 |     fix x assume x: "x \<in> {0..?n}"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 592 | hence "x = subdegree f \<or> x < subdegree f \<or> ?n - x < subdegree g" by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 593 | thus "f $ x * g $ (?n - x) = (if x = subdegree f then f $ x * g $ (?n - x) else 0)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 594 | by (elim disjE conjE) auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 595 | qed auto | 
| 64267 | 596 | also have "... = f $ subdegree f * g $ subdegree g" by (simp add: sum.delta) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 597 | finally show ?thesis . | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 598 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 599 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 600 | lemma subdegree_mult [simp]: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 601 | assumes "f \<noteq> 0" "g \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 602 |   shows "subdegree ((f :: ('a :: {ring_no_zero_divisors}) fps) * g) = subdegree f + subdegree g"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 603 | proof (rule subdegreeI) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 604 | let ?n = "subdegree f + subdegree g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 605 | have "(f * g) $ ?n = (\<Sum>i=0..?n. f$i * g$(?n-i))" by (simp add: fps_mult_nth) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 606 | also have "... = (\<Sum>i=0..?n. if i = subdegree f then f$i * g$(?n-i) else 0)" | 
| 64267 | 607 | proof (intro sum.cong) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 608 |     fix x assume x: "x \<in> {0..?n}"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 609 | hence "x = subdegree f \<or> x < subdegree f \<or> ?n - x < subdegree g" by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 610 | thus "f $ x * g $ (?n - x) = (if x = subdegree f then f $ x * g $ (?n - x) else 0)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 611 | by (elim disjE conjE) auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 612 | qed auto | 
| 64267 | 613 | also have "... = f $ subdegree f * g $ subdegree g" by (simp add: sum.delta) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 614 | also from assms have "... \<noteq> 0" by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 615 | finally show "(f * g) $ (subdegree f + subdegree g) \<noteq> 0" . | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 616 | next | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 617 | fix m assume m: "m < subdegree f + subdegree g" | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 618 | have "(f * g) $ m = (\<Sum>i=0..m. f$i * g$(m-i))" by (simp add: fps_mult_nth) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 619 | also have "... = (\<Sum>i=0..m. 0)" | 
| 64267 | 620 | proof (rule sum.cong) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 621 |     fix i assume "i \<in> {0..m}"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 622 | with m have "i < subdegree f \<or> m - i < subdegree g" by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 623 | thus "f$i * g$(m-i) = 0" by (elim disjE) auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 624 | qed auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 625 | finally show "(f * g) $ m = 0" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 626 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 627 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 628 | lemma subdegree_power [simp]: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 629 |   "subdegree ((f :: ('a :: ring_1_no_zero_divisors) fps) ^ n) = n * subdegree f"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 630 | by (cases "f = 0"; induction n) simp_all | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 631 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 632 | lemma subdegree_uminus [simp]: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 633 |   "subdegree (-(f::('a::group_add) fps)) = subdegree f"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 634 | by (simp add: subdegree_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 635 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 636 | lemma subdegree_minus_commute [simp]: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 637 |   "subdegree (f-(g::('a::group_add) fps)) = subdegree (g - f)"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 638 | proof - | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 639 | have "f - g = -(g - f)" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 640 | also have "subdegree ... = subdegree (g - f)" by (simp only: subdegree_uminus) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 641 | finally show ?thesis . | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 642 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 643 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 644 | lemma subdegree_add_ge: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 645 |   assumes "f \<noteq> -(g :: ('a :: {group_add}) fps)"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 646 | shows "subdegree (f + g) \<ge> min (subdegree f) (subdegree g)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 647 | proof (rule subdegree_geI) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 648 | from assms show "f + g \<noteq> 0" by (subst (asm) eq_neg_iff_add_eq_0) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 649 | next | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 650 | fix i assume "i < min (subdegree f) (subdegree g)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 651 | hence "f $ i = 0" and "g $ i = 0" by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 652 | thus "(f + g) $ i = 0" by force | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 653 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 654 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 655 | lemma subdegree_add_eq1: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 656 | assumes "f \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 657 |   assumes "subdegree f < subdegree (g :: ('a :: {group_add}) fps)"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 658 | shows "subdegree (f + g) = subdegree f" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 659 | proof (rule antisym[OF subdegree_leI]) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 660 | from assms show "subdegree (f + g) \<ge> subdegree f" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 661 | by (intro order.trans[OF min.boundedI subdegree_add_ge]) auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 662 | from assms have "f $ subdegree f \<noteq> 0" "g $ subdegree f = 0" by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 663 | thus "(f + g) $ subdegree f \<noteq> 0" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 664 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 665 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 666 | lemma subdegree_add_eq2: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 667 | assumes "g \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 668 |   assumes "subdegree g < subdegree (f :: ('a :: {ab_group_add}) fps)"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 669 | shows "subdegree (f + g) = subdegree g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 670 | using subdegree_add_eq1[OF assms] by (simp add: add.commute) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 671 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 672 | lemma subdegree_diff_eq1: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 673 | assumes "f \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 674 |   assumes "subdegree f < subdegree (g :: ('a :: {ab_group_add}) fps)"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 675 | shows "subdegree (f - g) = subdegree f" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 676 | using subdegree_add_eq1[of f "-g"] assms by (simp add: add.commute) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 677 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 678 | lemma subdegree_diff_eq2: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 679 | assumes "g \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 680 |   assumes "subdegree g < subdegree (f :: ('a :: {ab_group_add}) fps)"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 681 | shows "subdegree (f - g) = subdegree g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 682 | using subdegree_add_eq2[of "-g" f] assms by (simp add: add.commute) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 683 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 684 | lemma subdegree_diff_ge [simp]: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 685 |   assumes "f \<noteq> (g :: ('a :: {group_add}) fps)"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 686 | shows "subdegree (f - g) \<ge> min (subdegree f) (subdegree g)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 687 | using assms subdegree_add_ge[of f "-g"] by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 688 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 689 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 690 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 691 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 692 | subsection \<open>Shifting and slicing\<close> | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 693 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 694 | definition fps_shift :: "nat \<Rightarrow> 'a fps \<Rightarrow> 'a fps" where | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 695 | "fps_shift n f = Abs_fps (\<lambda>i. f $ (i + n))" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 696 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 697 | lemma fps_shift_nth [simp]: "fps_shift n f $ i = f $ (i + n)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 698 | by (simp add: fps_shift_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 699 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 700 | lemma fps_shift_0 [simp]: "fps_shift 0 f = f" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 701 | by (intro fps_ext) (simp add: fps_shift_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 702 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 703 | lemma fps_shift_zero [simp]: "fps_shift n 0 = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 704 | by (intro fps_ext) (simp add: fps_shift_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 705 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 706 | lemma fps_shift_one: "fps_shift n 1 = (if n = 0 then 1 else 0)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 707 | by (intro fps_ext) (simp add: fps_shift_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 708 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 709 | lemma fps_shift_fps_const: "fps_shift n (fps_const c) = (if n = 0 then fps_const c else 0)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 710 | by (intro fps_ext) (simp add: fps_shift_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 711 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 712 | lemma fps_shift_numeral: "fps_shift n (numeral c) = (if n = 0 then numeral c else 0)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 713 | by (simp add: numeral_fps_const fps_shift_fps_const) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 714 | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 715 | lemma fps_shift_X_power [simp]: | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 716 | "n \<le> m \<Longrightarrow> fps_shift n (X ^ m) = (X ^ (m - n) ::'a::comm_ring_1 fps)" | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 717 | by (intro fps_ext) (auto simp: fps_shift_def ) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 718 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 719 | lemma fps_shift_times_X_power: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 720 | "n \<le> subdegree f \<Longrightarrow> fps_shift n f * X ^ n = (f :: 'a :: comm_ring_1 fps)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 721 | by (intro fps_ext) (auto simp: X_power_mult_right_nth nth_less_subdegree_zero) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 722 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 723 | lemma fps_shift_times_X_power' [simp]: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 724 | "fps_shift n (f * X^n) = (f :: 'a :: comm_ring_1 fps)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 725 | by (intro fps_ext) (auto simp: X_power_mult_right_nth nth_less_subdegree_zero) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 726 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 727 | lemma fps_shift_times_X_power'': | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 728 | "m \<le> n \<Longrightarrow> fps_shift n (f * X^m) = fps_shift (n - m) (f :: 'a :: comm_ring_1 fps)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 729 | by (intro fps_ext) (auto simp: X_power_mult_right_nth nth_less_subdegree_zero) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 730 | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 731 | lemma fps_shift_subdegree [simp]: | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 732 | "n \<le> subdegree f \<Longrightarrow> subdegree (fps_shift n f) = subdegree (f :: 'a :: comm_ring_1 fps) - n" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 733 | by (cases "f = 0") (force intro: nth_less_subdegree_zero subdegreeI)+ | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 734 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 735 | lemma subdegree_decompose: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 736 |   "f = fps_shift (subdegree f) f * X ^ subdegree (f :: ('a :: comm_ring_1) fps)"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 737 | by (rule fps_ext) (auto simp: X_power_mult_right_nth) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 738 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 739 | lemma subdegree_decompose': | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 740 |   "n \<le> subdegree (f :: ('a :: comm_ring_1) fps) \<Longrightarrow> f = fps_shift n f * X^n"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 741 | by (rule fps_ext) (auto simp: X_power_mult_right_nth intro!: nth_less_subdegree_zero) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 742 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 743 | lemma fps_shift_fps_shift: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 744 | "fps_shift (m + n) f = fps_shift m (fps_shift n f)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 745 | by (rule fps_ext) (simp add: add_ac) | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 746 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 747 | lemma fps_shift_add: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 748 | "fps_shift n (f + g) = fps_shift n f + fps_shift n g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 749 | by (simp add: fps_eq_iff) | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 750 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 751 | lemma fps_shift_mult: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 752 |   assumes "n \<le> subdegree (g :: 'b :: {comm_ring_1} fps)"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 753 | shows "fps_shift n (h*g) = h * fps_shift n g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 754 | proof - | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 755 | from assms have "g = fps_shift n g * X^n" by (rule subdegree_decompose') | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 756 | also have "h * ... = (h * fps_shift n g) * X^n" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 757 | also have "fps_shift n ... = h * fps_shift n g" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 758 | finally show ?thesis . | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 759 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 760 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 761 | lemma fps_shift_mult_right: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 762 |   assumes "n \<le> subdegree (g :: 'b :: {comm_ring_1} fps)"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 763 | shows "fps_shift n (g*h) = h * fps_shift n g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 764 | by (subst mult.commute, subst fps_shift_mult) (simp_all add: assms) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 765 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 766 | lemma nth_subdegree_zero_iff [simp]: "f $ subdegree f = 0 \<longleftrightarrow> f = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 767 | by (cases "f = 0") auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 768 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 769 | lemma fps_shift_subdegree_zero_iff [simp]: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 770 | "fps_shift (subdegree f) f = 0 \<longleftrightarrow> f = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 771 | by (subst (1) nth_subdegree_zero_iff[symmetric], cases "f = 0") | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 772 | (simp_all del: nth_subdegree_zero_iff) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 773 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 774 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 775 | definition "fps_cutoff n f = Abs_fps (\<lambda>i. if i < n then f$i else 0)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 776 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 777 | lemma fps_cutoff_nth [simp]: "fps_cutoff n f $ i = (if i < n then f$i else 0)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 778 | unfolding fps_cutoff_def by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 779 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 780 | lemma fps_cutoff_zero_iff: "fps_cutoff n f = 0 \<longleftrightarrow> (f = 0 \<or> n \<le> subdegree f)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 781 | proof | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 782 | assume A: "fps_cutoff n f = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 783 | thus "f = 0 \<or> n \<le> subdegree f" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 784 | proof (cases "f = 0") | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 785 | assume "f \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 786 | with A have "n \<le> subdegree f" | 
| 62390 | 787 | by (intro subdegree_geI) (auto simp: fps_eq_iff split: if_split_asm) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 788 | thus ?thesis .. | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 789 | qed simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 790 | qed (auto simp: fps_eq_iff intro: nth_less_subdegree_zero) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 791 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 792 | lemma fps_cutoff_0 [simp]: "fps_cutoff 0 f = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 793 | by (simp add: fps_eq_iff) | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 794 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 795 | lemma fps_cutoff_zero [simp]: "fps_cutoff n 0 = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 796 | by (simp add: fps_eq_iff) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 797 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 798 | lemma fps_cutoff_one: "fps_cutoff n 1 = (if n = 0 then 0 else 1)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 799 | by (simp add: fps_eq_iff) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 800 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 801 | lemma fps_cutoff_fps_const: "fps_cutoff n (fps_const c) = (if n = 0 then 0 else fps_const c)" | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 802 | by (simp add: fps_eq_iff) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 803 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 804 | lemma fps_cutoff_numeral: "fps_cutoff n (numeral c) = (if n = 0 then 0 else numeral c)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 805 | by (simp add: numeral_fps_const fps_cutoff_fps_const) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 806 | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 807 | lemma fps_shift_cutoff: | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 808 |   "fps_shift n (f :: ('a :: comm_ring_1) fps) * X^n + fps_cutoff n f = f"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 809 | by (simp add: fps_eq_iff X_power_mult_right_nth) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 810 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 811 | |
| 60501 | 812 | subsection \<open>Formal Power series form a metric space\<close> | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 813 | |
| 52902 | 814 | definition (in dist) "ball x r = {y. dist y x < r}"
 | 
| 48757 | 815 | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 816 | instantiation fps :: (comm_ring_1) dist | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 817 | begin | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 818 | |
| 52891 | 819 | definition | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 820 | dist_fps_def: "dist (a :: 'a fps) b = (if a = b then 0 else inverse (2 ^ subdegree (a - b)))" | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 821 | |
| 54681 | 822 | lemma dist_fps_ge0: "dist (a :: 'a fps) b \<ge> 0" | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 823 | by (simp add: dist_fps_def) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 824 | |
| 54681 | 825 | lemma dist_fps_sym: "dist (a :: 'a fps) b = dist b a" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 826 | by (simp add: dist_fps_def) | 
| 48757 | 827 | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 828 | instance .. | 
| 48757 | 829 | |
| 30746 | 830 | end | 
| 831 | ||
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 832 | instantiation fps :: (comm_ring_1) metric_space | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 833 | begin | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 834 | |
| 62101 | 835 | definition uniformity_fps_def [code del]: | 
| 836 |   "(uniformity :: ('a fps \<times> 'a fps) filter) = (INF e:{0 <..}. principal {(x, y). dist x y < e})"
 | |
| 837 | ||
| 838 | definition open_fps_def' [code del]: | |
| 839 | "open (U :: 'a fps set) \<longleftrightarrow> (\<forall>x\<in>U. eventually (\<lambda>(x', y). x' = x \<longrightarrow> y \<in> U) uniformity)" | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 840 | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 841 | instance | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 842 | proof | 
| 60501 | 843 | show th: "dist a b = 0 \<longleftrightarrow> a = b" for a b :: "'a fps" | 
| 62390 | 844 | by (simp add: dist_fps_def split: if_split_asm) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 845 | then have th'[simp]: "dist a a = 0" for a :: "'a fps" by simp | 
| 60501 | 846 | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 847 | fix a b c :: "'a fps" | 
| 60501 | 848 | consider "a = b" | "c = a \<or> c = b" | "a \<noteq> b" "a \<noteq> c" "b \<noteq> c" by blast | 
| 849 | then show "dist a b \<le> dist a c + dist b c" | |
| 850 | proof cases | |
| 851 | case 1 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 852 | then show ?thesis by (simp add: dist_fps_def) | 
| 60501 | 853 | next | 
| 854 | case 2 | |
| 855 | then show ?thesis | |
| 52891 | 856 | by (cases "c = a") (simp_all add: th dist_fps_sym) | 
| 60501 | 857 | next | 
| 60567 | 858 | case neq: 3 | 
| 60558 | 859 | have False if "dist a b > dist a c + dist b c" | 
| 860 | proof - | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 861 | let ?n = "subdegree (a - b)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 862 | from neq have "dist a b > 0" "dist b c > 0" and "dist a c > 0" by (simp_all add: dist_fps_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 863 | with that have "dist a b > dist a c" and "dist a b > dist b c" by simp_all | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 864 | with neq have "?n < subdegree (a - c)" and "?n < subdegree (b - c)" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 865 | by (simp_all add: dist_fps_def field_simps) | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 866 | hence "(a - c) $ ?n = 0" and "(b - c) $ ?n = 0" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 867 | by (simp_all only: nth_less_subdegree_zero) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 868 | hence "(a - b) $ ?n = 0" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 869 | moreover from neq have "(a - b) $ ?n \<noteq> 0" by (intro nth_subdegree_nonzero) simp_all | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 870 | ultimately show False by contradiction | 
| 60558 | 871 | qed | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 872 | thus ?thesis by (auto simp add: not_le[symmetric]) | 
| 60501 | 873 | qed | 
| 62101 | 874 | qed (rule open_fps_def' uniformity_fps_def)+ | 
| 52891 | 875 | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 876 | end | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 877 | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 878 | declare uniformity_Abort[where 'a="'a :: comm_ring_1 fps", code] | 
| 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 879 | |
| 62101 | 880 | lemma open_fps_def: "open (S :: 'a::comm_ring_1 fps set) = (\<forall>a \<in> S. \<exists>r. r >0 \<and> ball a r \<subseteq> S)" | 
| 881 | unfolding open_dist ball_def subset_eq by simp | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 882 | |
| 60558 | 883 | text \<open>The infinite sums and justification of the notation in textbooks.\<close> | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 884 | |
| 52891 | 885 | lemma reals_power_lt_ex: | 
| 54681 | 886 | fixes x y :: real | 
| 887 | assumes xp: "x > 0" | |
| 888 | and y1: "y > 1" | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 889 | shows "\<exists>k>0. (1/y)^k < x" | 
| 52891 | 890 | proof - | 
| 54681 | 891 | have yp: "y > 0" | 
| 892 | using y1 by simp | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 893 | from reals_Archimedean2[of "max 0 (- log y x) + 1"] | 
| 54681 | 894 | obtain k :: nat where k: "real k > max 0 (- log y x) + 1" | 
| 895 | by blast | |
| 896 | from k have kp: "k > 0" | |
| 897 | by simp | |
| 898 | from k have "real k > - log y x" | |
| 899 | by simp | |
| 900 | then have "ln y * real k > - ln x" | |
| 901 | unfolding log_def | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 902 | using ln_gt_zero_iff[OF yp] y1 | 
| 54681 | 903 | by (simp add: minus_divide_left field_simps del: minus_divide_left[symmetric]) | 
| 904 | then have "ln y * real k + ln x > 0" | |
| 905 | by simp | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 906 | then have "exp (real k * ln y + ln x) > exp 0" | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 907 | by (simp add: ac_simps) | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 908 | then have "y ^ k * x > 1" | 
| 52891 | 909 | unfolding exp_zero exp_add exp_real_of_nat_mult exp_ln [OF xp] exp_ln [OF yp] | 
| 910 | by simp | |
| 911 | then have "x > (1 / y)^k" using yp | |
| 60867 | 912 | by (simp add: field_simps) | 
| 54681 | 913 | then show ?thesis | 
| 914 | using kp by blast | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 915 | qed | 
| 52891 | 916 | |
| 64267 | 917 | lemma fps_sum_rep_nth: "(sum (\<lambda>i. fps_const(a$i)*X^i) {0..m})$n =
 | 
| 54681 | 918 | (if n \<le> m then a$n else 0::'a::comm_ring_1)" | 
| 64267 | 919 | apply (auto simp add: fps_sum_nth cond_value_iff cong del: if_weak_cong) | 
| 920 | apply (simp add: sum.delta') | |
| 48757 | 921 | done | 
| 52891 | 922 | |
| 64267 | 923 | lemma fps_notation: "(\<lambda>n. sum (\<lambda>i. fps_const(a$i) * X^i) {0..n}) \<longlonglongrightarrow> a"
 | 
| 61969 | 924 | (is "?s \<longlonglongrightarrow> a") | 
| 52891 | 925 | proof - | 
| 60558 | 926 | have "\<exists>n0. \<forall>n \<ge> n0. dist (?s n) a < r" if "r > 0" for r | 
| 927 | proof - | |
| 60501 | 928 | obtain n0 where n0: "(1/2)^n0 < r" "n0 > 0" | 
| 929 | using reals_power_lt_ex[OF \<open>r > 0\<close>, of 2] by auto | |
| 60558 | 930 | show ?thesis | 
| 60501 | 931 | proof - | 
| 60558 | 932 | have "dist (?s n) a < r" if nn0: "n \<ge> n0" for n | 
| 933 | proof - | |
| 934 | from that have thnn0: "(1/2)^n \<le> (1/2 :: real)^n0" | |
| 60501 | 935 | by (simp add: divide_simps) | 
| 60558 | 936 | show ?thesis | 
| 60501 | 937 | proof (cases "?s n = a") | 
| 938 | case True | |
| 939 | then show ?thesis | |
| 940 | unfolding dist_eq_0_iff[of "?s n" a, symmetric] | |
| 941 | using \<open>r > 0\<close> by (simp del: dist_eq_0_iff) | |
| 942 | next | |
| 943 | case False | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 944 | from False have dth: "dist (?s n) a = (1/2)^subdegree (?s n - a)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 945 | by (simp add: dist_fps_def field_simps) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 946 | from False have kn: "subdegree (?s n - a) > n" | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 947 | by (intro subdegree_greaterI) (simp_all add: fps_sum_rep_nth) | 
| 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 948 | then have "dist (?s n) a < (1/2)^n" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 949 | by (simp add: field_simps dist_fps_def) | 
| 60501 | 950 | also have "\<dots> \<le> (1/2)^n0" | 
| 951 | using nn0 by (simp add: divide_simps) | |
| 952 | also have "\<dots> < r" | |
| 953 | using n0 by simp | |
| 954 | finally show ?thesis . | |
| 955 | qed | |
| 60558 | 956 | qed | 
| 60501 | 957 | then show ?thesis by blast | 
| 958 | qed | |
| 60558 | 959 | qed | 
| 54681 | 960 | then show ?thesis | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59867diff
changeset | 961 | unfolding lim_sequentially by blast | 
| 52891 | 962 | qed | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 963 | |
| 54681 | 964 | |
| 60501 | 965 | subsection \<open>Inverses of formal power series\<close> | 
| 29687 | 966 | |
| 64267 | 967 | declare sum.cong[fundef_cong] | 
| 29687 | 968 | |
| 60558 | 969 | instantiation fps :: ("{comm_monoid_add,inverse,times,uminus}") inverse
 | 
| 29687 | 970 | begin | 
| 971 | ||
| 52891 | 972 | fun natfun_inverse:: "'a fps \<Rightarrow> nat \<Rightarrow> 'a" | 
| 973 | where | |
| 29687 | 974 | "natfun_inverse f 0 = inverse (f$0)" | 
| 64267 | 975 | | "natfun_inverse f n = - inverse (f$0) * sum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n}"
 | 
| 29687 | 976 | |
| 60501 | 977 | definition fps_inverse_def: "inverse f = (if f $ 0 = 0 then 0 else Abs_fps (natfun_inverse f))" | 
| 978 | ||
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 979 | definition fps_divide_def: | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 980 | "f div g = (if g = 0 then 0 else | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 981 | let n = subdegree g; h = fps_shift n g | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 982 | in fps_shift n (f * inverse h))" | 
| 36311 
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
 haftmann parents: 
36309diff
changeset | 983 | |
| 29687 | 984 | instance .. | 
| 36311 
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
 haftmann parents: 
36309diff
changeset | 985 | |
| 29687 | 986 | end | 
| 987 | ||
| 52891 | 988 | lemma fps_inverse_zero [simp]: | 
| 54681 | 989 |   "inverse (0 :: 'a::{comm_monoid_add,inverse,times,uminus} fps) = 0"
 | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 990 | by (simp add: fps_ext fps_inverse_def) | 
| 29687 | 991 | |
| 52891 | 992 | lemma fps_inverse_one [simp]: "inverse (1 :: 'a::{division_ring,zero_neq_one} fps) = 1"
 | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 993 | apply (auto simp add: expand_fps_eq fps_inverse_def) | 
| 52891 | 994 | apply (case_tac n) | 
| 995 | apply auto | |
| 996 | done | |
| 997 | ||
| 998 | lemma inverse_mult_eq_1 [intro]: | |
| 999 | assumes f0: "f$0 \<noteq> (0::'a::field)" | |
| 29687 | 1000 | shows "inverse f * f = 1" | 
| 52891 | 1001 | proof - | 
| 54681 | 1002 | have c: "inverse f * f = f * inverse f" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 1003 | by (simp add: mult.commute) | 
| 30488 | 1004 | from f0 have ifn: "\<And>n. inverse f $ n = natfun_inverse f n" | 
| 29687 | 1005 | by (simp add: fps_inverse_def) | 
| 1006 | from f0 have th0: "(inverse f * f) $ 0 = 1" | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 1007 | by (simp add: fps_mult_nth fps_inverse_def) | 
| 60501 | 1008 | have "(inverse f * f)$n = 0" if np: "n > 0" for n | 
| 1009 | proof - | |
| 54681 | 1010 |     from np have eq: "{0..n} = {0} \<union> {1 .. n}"
 | 
| 1011 | by auto | |
| 1012 |     have d: "{0} \<inter> {1 .. n} = {}"
 | |
| 1013 | by auto | |
| 52891 | 1014 | from f0 np have th0: "- (inverse f $ n) = | 
| 64267 | 1015 |       (sum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n}) / (f$0)"
 | 
| 52891 | 1016 | by (cases n) (simp_all add: divide_inverse fps_inverse_def) | 
| 29687 | 1017 | from th0[symmetric, unfolded nonzero_divide_eq_eq[OF f0]] | 
| 64267 | 1018 |     have th1: "sum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n} = - (f$0) * (inverse f)$n"
 | 
| 36350 | 1019 | by (simp add: field_simps) | 
| 30488 | 1020 | have "(f * inverse f) $ n = (\<Sum>i = 0..n. f $i * natfun_inverse f (n - i))" | 
| 29687 | 1021 | unfolding fps_mult_nth ifn .. | 
| 52891 | 1022 | also have "\<dots> = f$0 * natfun_inverse f n + (\<Sum>i = 1..n. f$i * natfun_inverse f (n-i))" | 
| 46757 | 1023 | by (simp add: eq) | 
| 54681 | 1024 | also have "\<dots> = 0" | 
| 1025 | unfolding th1 ifn by simp | |
| 60501 | 1026 | finally show ?thesis unfolding c . | 
| 1027 | qed | |
| 54681 | 1028 | with th0 show ?thesis | 
| 1029 | by (simp add: fps_eq_iff) | |
| 29687 | 1030 | qed | 
| 1031 | ||
| 60501 | 1032 | lemma fps_inverse_0_iff[simp]: "(inverse f) $ 0 = (0::'a::division_ring) \<longleftrightarrow> f $ 0 = 0" | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 1033 | by (simp add: fps_inverse_def nonzero_imp_inverse_nonzero) | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1034 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1035 | lemma fps_inverse_nth_0 [simp]: "inverse f $ 0 = inverse (f $ 0 :: 'a :: division_ring)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1036 | by (simp add: fps_inverse_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1037 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1038 | lemma fps_inverse_eq_0_iff[simp]: "inverse f = (0:: ('a::division_ring) fps) \<longleftrightarrow> f $ 0 = 0"
 | 
| 60501 | 1039 | proof | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1040 | assume A: "inverse f = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1041 | have "0 = inverse f $ 0" by (subst A) simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1042 | thus "f $ 0 = 0" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1043 | qed (simp add: fps_inverse_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1044 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1045 | lemma fps_inverse_idempotent[intro, simp]: | 
| 48757 | 1046 | assumes f0: "f$0 \<noteq> (0::'a::field)" | 
| 29687 | 1047 | shows "inverse (inverse f) = f" | 
| 52891 | 1048 | proof - | 
| 29687 | 1049 | from f0 have if0: "inverse f $ 0 \<noteq> 0" by simp | 
| 30488 | 1050 | from inverse_mult_eq_1[OF f0] inverse_mult_eq_1[OF if0] | 
| 52891 | 1051 | have "inverse f * f = inverse f * inverse (inverse f)" | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 1052 | by (simp add: ac_simps) | 
| 54681 | 1053 | then show ?thesis | 
| 1054 | using f0 unfolding mult_cancel_left by simp | |
| 29687 | 1055 | qed | 
| 1056 | ||
| 48757 | 1057 | lemma fps_inverse_unique: | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1058 | assumes fg: "(f :: 'a :: field fps) * g = 1" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1059 | shows "inverse f = g" | 
| 52891 | 1060 | proof - | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1061 | have f0: "f $ 0 \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1062 | proof | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1063 | assume "f $ 0 = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1064 | hence "0 = (f * g) $ 0" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1065 | also from fg have "(f * g) $ 0 = 1" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1066 | finally show False by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1067 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1068 | from inverse_mult_eq_1[OF this] fg | 
| 54681 | 1069 | have th0: "inverse f * f = g * f" | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 1070 | by (simp add: ac_simps) | 
| 54681 | 1071 | then show ?thesis | 
| 1072 | using f0 | |
| 1073 | unfolding mult_cancel_right | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 1074 | by (auto simp add: expand_fps_eq) | 
| 29687 | 1075 | qed | 
| 1076 | ||
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1077 | lemma fps_inverse_eq_0: "f$0 = 0 \<Longrightarrow> inverse (f :: 'a :: division_ring fps) = 0" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1078 | by simp | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1079 | |
| 64267 | 1080 | lemma sum_zero_lemma: | 
| 60162 | 1081 | fixes n::nat | 
| 1082 | assumes "0 < n" | |
| 1083 | shows "(\<Sum>i = 0..n. if n = i then 1 else if n - i = 1 then - 1 else 0) = (0::'a::field)" | |
| 54681 | 1084 | proof - | 
| 60162 | 1085 | let ?f = "\<lambda>i. if n = i then 1 else if n - i = 1 then - 1 else 0" | 
| 1086 | let ?g = "\<lambda>i. if i = n then 1 else if i = n - 1 then - 1 else 0" | |
| 29687 | 1087 | let ?h = "\<lambda>i. if i=n - 1 then - 1 else 0" | 
| 64267 | 1088 |   have th1: "sum ?f {0..n} = sum ?g {0..n}"
 | 
| 1089 | by (rule sum.cong) auto | |
| 1090 |   have th2: "sum ?g {0..n - 1} = sum ?h {0..n - 1}"
 | |
| 1091 | apply (rule sum.cong) | |
| 60162 | 1092 | using assms | 
| 54681 | 1093 | apply auto | 
| 1094 | done | |
| 1095 |   have eq: "{0 .. n} = {0.. n - 1} \<union> {n}"
 | |
| 1096 | by auto | |
| 60162 | 1097 |   from assms have d: "{0.. n - 1} \<inter> {n} = {}"
 | 
| 54681 | 1098 | by auto | 
| 1099 |   have f: "finite {0.. n - 1}" "finite {n}"
 | |
| 1100 | by auto | |
| 60162 | 1101 | show ?thesis | 
| 30488 | 1102 | unfolding th1 | 
| 64267 | 1103 | apply (simp add: sum.union_disjoint[OF f d, unfolded eq[symmetric]] del: One_nat_def) | 
| 29687 | 1104 | unfolding th2 | 
| 64267 | 1105 | apply (simp add: sum.delta) | 
| 52891 | 1106 | done | 
| 29687 | 1107 | qed | 
| 1108 | ||
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1109 | lemma fps_inverse_mult: "inverse (f * g :: 'a::field fps) = inverse f * inverse g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1110 | proof (cases "f$0 = 0 \<or> g$0 = 0") | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1111 | assume "\<not>(f$0 = 0 \<or> g$0 = 0)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1112 | hence [simp]: "f$0 \<noteq> 0" "g$0 \<noteq> 0" by simp_all | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1113 | show ?thesis | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1114 | proof (rule fps_inverse_unique) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1115 | have "f * g * (inverse f * inverse g) = (inverse f * f) * (inverse g * g)" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1116 | also have "... = 1" by (subst (1 2) inverse_mult_eq_1) simp_all | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1117 | finally show "f * g * (inverse f * inverse g) = 1" . | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1118 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1119 | next | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1120 | assume A: "f$0 = 0 \<or> g$0 = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1121 | hence "inverse (f * g) = 0" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1122 | also from A have "... = inverse f * inverse g" by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1123 | finally show "inverse (f * g) = inverse f * inverse g" . | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1124 | qed | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1125 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1126 | |
| 60501 | 1127 | lemma fps_inverse_gp: "inverse (Abs_fps(\<lambda>n. (1::'a::field))) = | 
| 1128 | Abs_fps (\<lambda>n. if n= 0 then 1 else if n=1 then - 1 else 0)" | |
| 60162 | 1129 | apply (rule fps_inverse_unique) | 
| 64267 | 1130 | apply (simp_all add: fps_eq_iff fps_mult_nth sum_zero_lemma) | 
| 60162 | 1131 | done | 
| 1132 | ||
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1133 | lemma subdegree_inverse [simp]: "subdegree (inverse (f::'a::field fps)) = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1134 | proof (cases "f$0 = 0") | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1135 | assume nz: "f$0 \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1136 | hence "subdegree (inverse f) + subdegree f = subdegree (inverse f * f)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1137 | by (subst subdegree_mult) auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1138 | also from nz have "subdegree f = 0" by (simp add: subdegree_eq_0_iff) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1139 | also from nz have "inverse f * f = 1" by (rule inverse_mult_eq_1) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1140 | finally show "subdegree (inverse f) = 0" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1141 | qed (simp_all add: fps_inverse_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1142 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1143 | lemma fps_is_unit_iff [simp]: "(f :: 'a :: field fps) dvd 1 \<longleftrightarrow> f $ 0 \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1144 | proof | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1145 | assume "f dvd 1" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1146 | then obtain g where "1 = f * g" by (elim dvdE) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1147 | from this[symmetric] have "(f*g) $ 0 = 1" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1148 | thus "f $ 0 \<noteq> 0" by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1149 | next | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1150 | assume A: "f $ 0 \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1151 | thus "f dvd 1" by (simp add: inverse_mult_eq_1[OF A, symmetric]) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1152 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1153 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1154 | lemma subdegree_eq_0' [simp]: "(f :: 'a :: field fps) dvd 1 \<Longrightarrow> subdegree f = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1155 | by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1156 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1157 | lemma fps_unit_dvd [simp]: "(f $ 0 :: 'a :: field) \<noteq> 0 \<Longrightarrow> f dvd g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1158 | by (rule dvd_trans, subst fps_is_unit_iff) simp_all | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1159 | |
| 64592 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1160 | instantiation fps :: (field) normalization_semidom | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1161 | begin | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1162 | |
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1163 | definition fps_unit_factor_def [simp]: | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1164 | "unit_factor f = fps_shift (subdegree f) f" | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1165 | |
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1166 | definition fps_normalize_def [simp]: | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1167 | "normalize f = (if f = 0 then 0 else X ^ subdegree f)" | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1168 | |
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1169 | instance proof | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1170 | fix f :: "'a fps" | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1171 | show "unit_factor f * normalize f = f" | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1172 | by (simp add: fps_shift_times_X_power) | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1173 | next | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1174 | fix f g :: "'a fps" | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1175 | show "unit_factor (f * g) = unit_factor f * unit_factor g" | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1176 | proof (cases "f = 0 \<or> g = 0") | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1177 | assume "\<not>(f = 0 \<or> g = 0)" | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1178 | thus "unit_factor (f * g) = unit_factor f * unit_factor g" | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1179 | unfolding fps_unit_factor_def | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1180 | by (auto simp: fps_shift_fps_shift fps_shift_mult fps_shift_mult_right) | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1181 | qed auto | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1182 | next | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1183 | fix f g :: "'a fps" | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1184 | assume "g \<noteq> 0" | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1185 | then have "f * (fps_shift (subdegree g) g * inverse (fps_shift (subdegree g) g)) = f" | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1186 | by (metis add_cancel_right_left fps_shift_nth inverse_mult_eq_1 mult.commute mult_cancel_left2 nth_subdegree_nonzero) | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1187 | then have "fps_shift (subdegree g) (g * (f * inverse (fps_shift (subdegree g) g))) = f" | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1188 | by (simp add: fps_shift_mult_right mult.commute) | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1189 | with \<open>g \<noteq> 0\<close> show "f * g / g = f" | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1190 | by (simp add: fps_divide_def Let_def ac_simps) | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1191 | qed (auto simp add: fps_divide_def Let_def) | 
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1192 | |
| 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1193 | end | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1194 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1195 | instantiation fps :: (field) ring_div | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1196 | begin | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1197 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1198 | definition fps_mod_def: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1199 | "f mod g = (if g = 0 then f else | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1200 | let n = subdegree g; h = fps_shift n g | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1201 | in fps_cutoff n (f * inverse h) * h)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1202 | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1203 | lemma fps_mod_eq_zero: | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1204 | assumes "g \<noteq> 0" and "subdegree f \<ge> subdegree g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1205 | shows "f mod g = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1206 | using assms by (cases "f = 0") (auto simp: fps_cutoff_zero_iff fps_mod_def Let_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1207 | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1208 | lemma fps_times_divide_eq: | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1209 | assumes "g \<noteq> 0" and "subdegree f \<ge> subdegree (g :: 'a fps)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1210 | shows "f div g * g = f" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1211 | proof (cases "f = 0") | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1212 | assume nz: "f \<noteq> 0" | 
| 63040 | 1213 | define n where "n = subdegree g" | 
| 1214 | define h where "h = fps_shift n g" | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1215 | from assms have [simp]: "h $ 0 \<noteq> 0" unfolding h_def by (simp add: n_def) | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1216 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1217 | from assms nz have "f div g * g = fps_shift n (f * inverse h) * g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1218 | by (simp add: fps_divide_def Let_def h_def n_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1219 | also have "... = fps_shift n (f * inverse h) * X^n * h" unfolding h_def n_def | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1220 | by (subst subdegree_decompose[of g]) simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1221 | also have "fps_shift n (f * inverse h) * X^n = f * inverse h" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1222 | by (rule fps_shift_times_X_power) (simp_all add: nz assms n_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1223 | also have "... * h = f * (inverse h * h)" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1224 | also have "inverse h * h = 1" by (rule inverse_mult_eq_1) simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1225 | finally show ?thesis by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1226 | qed (simp_all add: fps_divide_def Let_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1227 | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1228 | lemma | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1229 | assumes "g$0 \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1230 | shows fps_divide_unit: "f div g = f * inverse g" and fps_mod_unit [simp]: "f mod g = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1231 | proof - | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1232 | from assms have [simp]: "subdegree g = 0" by (simp add: subdegree_eq_0_iff) | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1233 | from assms show "f div g = f * inverse g" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1234 | by (auto simp: fps_divide_def Let_def subdegree_eq_0_iff) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1235 | from assms show "f mod g = 0" by (intro fps_mod_eq_zero) auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1236 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1237 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1238 | context | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1239 | begin | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1240 | private lemma fps_divide_cancel_aux1: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1241 | assumes "h$0 \<noteq> (0 :: 'a :: field)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1242 | shows "(h * f) div (h * g) = f div g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1243 | proof (cases "g = 0") | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1244 | assume "g \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1245 | from assms have "h \<noteq> 0" by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1246 | note nz [simp] = \<open>g \<noteq> 0\<close> \<open>h \<noteq> 0\<close> | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1247 | from assms have [simp]: "subdegree h = 0" by (simp add: subdegree_eq_0_iff) | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1248 | |
| 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1249 | have "(h * f) div (h * g) = | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1250 | fps_shift (subdegree g) (h * f * inverse (fps_shift (subdegree g) (h*g)))" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1251 | by (simp add: fps_divide_def Let_def) | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1252 | also have "h * f * inverse (fps_shift (subdegree g) (h*g)) = | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1253 | (inverse h * h) * f * inverse (fps_shift (subdegree g) g)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1254 | by (subst fps_shift_mult) (simp_all add: algebra_simps fps_inverse_mult) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1255 | also from assms have "inverse h * h = 1" by (rule inverse_mult_eq_1) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1256 | finally show "(h * f) div (h * g) = f div g" by (simp_all add: fps_divide_def Let_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1257 | qed (simp_all add: fps_divide_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1258 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1259 | private lemma fps_divide_cancel_aux2: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1260 | "(f * X^m) div (g * X^m) = f div (g :: 'a :: field fps)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1261 | proof (cases "g = 0") | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1262 | assume [simp]: "g \<noteq> 0" | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1263 | have "(f * X^m) div (g * X^m) = | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1264 | fps_shift (subdegree g + m) (f*inverse (fps_shift (subdegree g + m) (g*X^m))*X^m)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1265 | by (simp add: fps_divide_def Let_def algebra_simps) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1266 | also have "... = f div g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1267 | by (simp add: fps_shift_times_X_power'' fps_divide_def Let_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1268 | finally show ?thesis . | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1269 | qed (simp_all add: fps_divide_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1270 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1271 | instance proof | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1272 | fix f g :: "'a fps" | 
| 63040 | 1273 | define n where "n = subdegree g" | 
| 1274 | define h where "h = fps_shift n g" | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1275 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1276 | show "f div g * g + f mod g = f" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1277 | proof (cases "g = 0 \<or> f = 0") | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1278 | assume "\<not>(g = 0 \<or> f = 0)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1279 | hence nz [simp]: "f \<noteq> 0" "g \<noteq> 0" by simp_all | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1280 | show ?thesis | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1281 | proof (rule disjE[OF le_less_linear]) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1282 | assume "subdegree f \<ge> subdegree g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1283 | with nz show ?thesis by (simp add: fps_mod_eq_zero fps_times_divide_eq) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1284 | next | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1285 | assume "subdegree f < subdegree g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1286 | have g_decomp: "g = h * X^n" unfolding h_def n_def by (rule subdegree_decompose) | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1287 | have "f div g * g + f mod g = | 
| 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1288 | fps_shift n (f * inverse h) * g + fps_cutoff n (f * inverse h) * h" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1289 | by (simp add: fps_mod_def fps_divide_def Let_def n_def h_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1290 | also have "... = h * (fps_shift n (f * inverse h) * X^n + fps_cutoff n (f * inverse h))" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1291 | by (subst g_decomp) (simp add: algebra_simps) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1292 | also have "... = f * (inverse h * h)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1293 | by (subst fps_shift_cutoff) simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1294 | also have "inverse h * h = 1" by (rule inverse_mult_eq_1) (simp add: h_def n_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1295 | finally show ?thesis by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1296 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1297 | qed (auto simp: fps_mod_def fps_divide_def Let_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1298 | next | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1299 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1300 | fix f g h :: "'a fps" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1301 | assume "h \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1302 | show "(h * f) div (h * g) = f div g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1303 | proof - | 
| 63040 | 1304 | define m where "m = subdegree h" | 
| 1305 | define h' where "h' = fps_shift m h" | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1306 | have h_decomp: "h = h' * X ^ m" unfolding h'_def m_def by (rule subdegree_decompose) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1307 | from \<open>h \<noteq> 0\<close> have [simp]: "h'$0 \<noteq> 0" by (simp add: h'_def m_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1308 | have "(h * f) div (h * g) = (h' * f * X^m) div (h' * g * X^m)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1309 | by (simp add: h_decomp algebra_simps) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1310 | also have "... = f div g" by (simp add: fps_divide_cancel_aux1 fps_divide_cancel_aux2) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1311 | finally show ?thesis . | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1312 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1313 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1314 | next | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1315 | fix f g h :: "'a fps" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1316 | assume [simp]: "h \<noteq> 0" | 
| 63040 | 1317 | define n h' where dfs: "n = subdegree h" "h' = fps_shift n h" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1318 | have "(f + g * h) div h = fps_shift n (f * inverse h') + fps_shift n (g * (h * inverse h'))" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1319 | by (simp add: fps_divide_def Let_def dfs[symmetric] algebra_simps fps_shift_add) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1320 | also have "h * inverse h' = (inverse h' * h') * X^n" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1321 | by (subst subdegree_decompose) (simp_all add: dfs) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1322 | also have "... = X^n" by (subst inverse_mult_eq_1) (simp_all add: dfs) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1323 | also have "fps_shift n (g * X^n) = g" by simp | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1324 | also have "fps_shift n (f * inverse h') = f div h" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1325 | by (simp add: fps_divide_def Let_def dfs) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1326 | finally show "(f + g * h) div h = g + f div h" by simp | 
| 64592 
7759f1766189
more fine-grained type class hierarchy for div and mod
 haftmann parents: 
64272diff
changeset | 1327 | qed | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1328 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1329 | end | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1330 | end | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1331 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1332 | lemma subdegree_mod: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1333 | assumes "f \<noteq> 0" "subdegree f < subdegree g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1334 | shows "subdegree (f mod g) = subdegree f" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1335 | proof (cases "f div g * g = 0") | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1336 | assume "f div g * g \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1337 | hence [simp]: "f div g \<noteq> 0" "g \<noteq> 0" by auto | 
| 64242 
93c6f0da5c70
more standardized theorem names for facts involving the div and mod identity
 haftmann parents: 
64240diff
changeset | 1338 | from div_mult_mod_eq[of f g] have "f mod g = f - f div g * g" by (simp add: algebra_simps) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1339 | also from assms have "subdegree ... = subdegree f" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1340 | by (intro subdegree_diff_eq1) simp_all | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1341 | finally show ?thesis . | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1342 | next | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1343 | assume zero: "f div g * g = 0" | 
| 64242 
93c6f0da5c70
more standardized theorem names for facts involving the div and mod identity
 haftmann parents: 
64240diff
changeset | 1344 | from div_mult_mod_eq[of f g] have "f mod g = f - f div g * g" by (simp add: algebra_simps) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1345 | also note zero | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1346 | finally show ?thesis by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1347 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1348 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1349 | lemma fps_divide_nth_0 [simp]: "g $ 0 \<noteq> 0 \<Longrightarrow> (f div g) $ 0 = f $ 0 / (g $ 0 :: _ :: field)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1350 | by (simp add: fps_divide_unit divide_inverse) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1351 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1352 | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1353 | lemma dvd_imp_subdegree_le: | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1354 | "(f :: 'a :: idom fps) dvd g \<Longrightarrow> g \<noteq> 0 \<Longrightarrow> subdegree f \<le> subdegree g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1355 | by (auto elim: dvdE) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1356 | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1357 | lemma fps_dvd_iff: | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1358 | assumes "(f :: 'a :: field fps) \<noteq> 0" "g \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1359 | shows "f dvd g \<longleftrightarrow> subdegree f \<le> subdegree g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1360 | proof | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1361 | assume "subdegree f \<le> subdegree g" | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1362 | with assms have "g mod f = 0" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1363 | by (simp add: fps_mod_def Let_def fps_cutoff_zero_iff) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1364 | thus "f dvd g" by (simp add: dvd_eq_mod_eq_0) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1365 | qed (simp add: assms dvd_imp_subdegree_le) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1366 | |
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1367 | lemma fps_shift_altdef: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1368 | "fps_shift n f = (f :: 'a :: field fps) div X^n" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1369 | by (simp add: fps_divide_def) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1370 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1371 | lemma fps_div_X_power_nth: "((f :: 'a :: field fps) div X^n) $ k = f $ (k + n)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1372 | by (simp add: fps_shift_altdef [symmetric]) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1373 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1374 | lemma fps_div_X_nth: "((f :: 'a :: field fps) div X) $ k = f $ Suc k" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1375 | using fps_div_X_power_nth[of f 1] by simp | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1376 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1377 | lemma fps_const_inverse: "inverse (fps_const (a::'a::field)) = fps_const (inverse a)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1378 | by (cases "a \<noteq> 0", rule fps_inverse_unique) (auto simp: fps_eq_iff) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1379 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1380 | lemma fps_const_divide: "fps_const (x :: _ :: field) / fps_const y = fps_const (x / y)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1381 | by (cases "y = 0") (simp_all add: fps_divide_unit fps_const_inverse divide_inverse) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1382 | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1383 | lemma inverse_fps_numeral: | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1384 |   "inverse (numeral n :: ('a :: field_char_0) fps) = fps_const (inverse (numeral n))"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1385 | by (intro fps_inverse_unique fps_ext) (simp_all add: fps_numeral_nth) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1386 | |
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1387 | lemma fps_numeral_divide_divide: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1388 | "x / numeral b / numeral c = (x / numeral (b * c) :: 'a :: field fps)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1389 | by (cases "numeral b = (0::'a)"; cases "numeral c = (0::'a)") | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1390 | (simp_all add: fps_divide_unit fps_inverse_mult [symmetric] numeral_fps_const numeral_mult | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1391 | del: numeral_mult [symmetric]) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1392 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1393 | lemma fps_numeral_mult_divide: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1394 | "numeral b * x / numeral c = (numeral b / numeral c * x :: 'a :: field fps)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1395 | by (cases "numeral c = (0::'a)") (simp_all add: fps_divide_unit numeral_fps_const) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1396 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1397 | lemmas fps_numeral_simps = | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1398 | fps_numeral_divide_divide fps_numeral_mult_divide inverse_fps_numeral neg_numeral_fps_const | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1399 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1400 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1401 | subsection \<open>Formal power series form a Euclidean ring\<close> | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1402 | |
| 64784 
5cb5e7ecb284
reshaped euclidean semiring into hierarchy of euclidean semirings culminating in uniquely determined euclidean divion
 haftmann parents: 
64592diff
changeset | 1403 | instantiation fps :: (field) euclidean_ring_cancel | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1404 | begin | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1405 | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1406 | definition fps_euclidean_size_def: | 
| 62422 | 1407 | "euclidean_size f = (if f = 0 then 0 else 2 ^ subdegree f)" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1408 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1409 | instance proof | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1410 | fix f g :: "'a fps" assume [simp]: "g \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1411 | show "euclidean_size f \<le> euclidean_size (f * g)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1412 | by (cases "f = 0") (auto simp: fps_euclidean_size_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1413 | show "euclidean_size (f mod g) < euclidean_size g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1414 | apply (cases "f = 0", simp add: fps_euclidean_size_def) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1415 | apply (rule disjE[OF le_less_linear[of "subdegree g" "subdegree f"]]) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1416 | apply (simp_all add: fps_mod_eq_zero fps_euclidean_size_def subdegree_mod) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1417 | done | 
| 62422 | 1418 | qed (simp_all add: fps_euclidean_size_def) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1419 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1420 | end | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1421 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1422 | instantiation fps :: (field) euclidean_ring_gcd | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1423 | begin | 
| 64786 
340db65fd2c1
reworked to provide auxiliary operations Euclidean_Algorithm.* to instantiate gcd etc. for euclidean rings
 haftmann parents: 
64784diff
changeset | 1424 | definition fps_gcd_def: "(gcd :: 'a fps \<Rightarrow> _) = Euclidean_Algorithm.gcd" | 
| 
340db65fd2c1
reworked to provide auxiliary operations Euclidean_Algorithm.* to instantiate gcd etc. for euclidean rings
 haftmann parents: 
64784diff
changeset | 1425 | definition fps_lcm_def: "(lcm :: 'a fps \<Rightarrow> _) = Euclidean_Algorithm.lcm" | 
| 
340db65fd2c1
reworked to provide auxiliary operations Euclidean_Algorithm.* to instantiate gcd etc. for euclidean rings
 haftmann parents: 
64784diff
changeset | 1426 | definition fps_Gcd_def: "(Gcd :: 'a fps set \<Rightarrow> _) = Euclidean_Algorithm.Gcd" | 
| 
340db65fd2c1
reworked to provide auxiliary operations Euclidean_Algorithm.* to instantiate gcd etc. for euclidean rings
 haftmann parents: 
64784diff
changeset | 1427 | definition fps_Lcm_def: "(Lcm :: 'a fps set \<Rightarrow> _) = Euclidean_Algorithm.Lcm" | 
| 62422 | 1428 | instance by standard (simp_all add: fps_gcd_def fps_lcm_def fps_Gcd_def fps_Lcm_def) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1429 | end | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1430 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1431 | lemma fps_gcd: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1432 | assumes [simp]: "f \<noteq> 0" "g \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1433 | shows "gcd f g = X ^ min (subdegree f) (subdegree g)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1434 | proof - | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1435 | let ?m = "min (subdegree f) (subdegree g)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1436 | show "gcd f g = X ^ ?m" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1437 | proof (rule sym, rule gcdI) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1438 | fix d assume "d dvd f" "d dvd g" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1439 | thus "d dvd X ^ ?m" by (cases "d = 0") (auto simp: fps_dvd_iff) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1440 | qed (simp_all add: fps_dvd_iff) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1441 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1442 | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1443 | lemma fps_gcd_altdef: "gcd (f :: 'a :: field fps) g = | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1444 | (if f = 0 \<and> g = 0 then 0 else | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1445 | if f = 0 then X ^ subdegree g else | 
| 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1446 | if g = 0 then X ^ subdegree f else | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1447 | X ^ min (subdegree f) (subdegree g))" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1448 | by (simp add: fps_gcd) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1449 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1450 | lemma fps_lcm: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1451 | assumes [simp]: "f \<noteq> 0" "g \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1452 | shows "lcm f g = X ^ max (subdegree f) (subdegree g)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1453 | proof - | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1454 | let ?m = "max (subdegree f) (subdegree g)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1455 | show "lcm f g = X ^ ?m" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1456 | proof (rule sym, rule lcmI) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1457 | fix d assume "f dvd d" "g dvd d" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1458 | thus "X ^ ?m dvd d" by (cases "d = 0") (auto simp: fps_dvd_iff) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1459 | qed (simp_all add: fps_dvd_iff) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1460 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1461 | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1462 | lemma fps_lcm_altdef: "lcm (f :: 'a :: field fps) g = | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1463 | (if f = 0 \<or> g = 0 then 0 else X ^ max (subdegree f) (subdegree g))" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1464 | by (simp add: fps_lcm) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1465 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1466 | lemma fps_Gcd: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1467 |   assumes "A - {0} \<noteq> {}"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1468 |   shows   "Gcd A = X ^ (INF f:A-{0}. subdegree f)"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1469 | proof (rule sym, rule GcdI) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1470 | fix f assume "f \<in> A" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1471 |   thus "X ^ (INF f:A - {0}. subdegree f) dvd f"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1472 | by (cases "f = 0") (auto simp: fps_dvd_iff intro!: cINF_lower) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1473 | next | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1474 | fix d assume d: "\<And>f. f \<in> A \<Longrightarrow> d dvd f" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1475 |   from assms obtain f where "f \<in> A - {0}" by auto
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1476 | with d[of f] have [simp]: "d \<noteq> 0" by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1477 |   from d assms have "subdegree d \<le> (INF f:A-{0}. subdegree f)"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1478 | by (intro cINF_greatest) (auto simp: fps_dvd_iff[symmetric]) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1479 |   with d assms show "d dvd X ^ (INF f:A-{0}. subdegree f)" by (simp add: fps_dvd_iff)
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1480 | qed simp_all | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1481 | |
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1482 | lemma fps_Gcd_altdef: "Gcd (A :: 'a :: field fps set) = | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1483 |   (if A \<subseteq> {0} then 0 else X ^ (INF f:A-{0}. subdegree f))"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1484 | using fps_Gcd by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1485 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1486 | lemma fps_Lcm: | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1487 |   assumes "A \<noteq> {}" "0 \<notin> A" "bdd_above (subdegree`A)"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1488 | shows "Lcm A = X ^ (SUP f:A. subdegree f)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1489 | proof (rule sym, rule LcmI) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1490 | fix f assume "f \<in> A" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1491 | moreover from assms(3) have "bdd_above (subdegree ` A)" by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1492 | ultimately show "f dvd X ^ (SUP f:A. subdegree f)" using assms(2) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1493 | by (cases "f = 0") (auto simp: fps_dvd_iff intro!: cSUP_upper) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1494 | next | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1495 | fix d assume d: "\<And>f. f \<in> A \<Longrightarrow> f dvd d" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1496 | from assms obtain f where f: "f \<in> A" "f \<noteq> 0" by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1497 | show "X ^ (SUP f:A. subdegree f) dvd d" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1498 | proof (cases "d = 0") | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1499 | assume "d \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1500 | moreover from d have "\<And>f. f \<in> A \<Longrightarrow> f \<noteq> 0 \<Longrightarrow> f dvd d" by blast | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1501 | ultimately have "subdegree d \<ge> (SUP f:A. subdegree f)" using assms | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1502 | by (intro cSUP_least) (auto simp: fps_dvd_iff) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1503 | with \<open>d \<noteq> 0\<close> show ?thesis by (simp add: fps_dvd_iff) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1504 | qed simp_all | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1505 | qed simp_all | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1506 | |
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1507 | lemma fps_Lcm_altdef: | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 1508 | "Lcm (A :: 'a :: field fps set) = | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1509 | (if 0 \<in> A \<or> \<not>bdd_above (subdegree`A) then 0 else | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1510 |       if A = {} then 1 else X ^ (SUP f:A. subdegree f))"
 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1511 | proof (cases "bdd_above (subdegree`A)") | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1512 | assume unbounded: "\<not>bdd_above (subdegree`A)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1513 | have "Lcm A = 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1514 | proof (rule ccontr) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1515 | assume "Lcm A \<noteq> 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1516 | from unbounded obtain f where f: "f \<in> A" "subdegree (Lcm A) < subdegree f" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1517 | unfolding bdd_above_def by (auto simp: not_le) | 
| 63539 | 1518 | moreover from f and \<open>Lcm A \<noteq> 0\<close> have "subdegree f \<le> subdegree (Lcm A)" | 
| 62422 | 1519 | by (intro dvd_imp_subdegree_le dvd_Lcm) simp_all | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1520 | ultimately show False by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1521 | qed | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1522 | with unbounded show ?thesis by simp | 
| 62422 | 1523 | qed (simp_all add: fps_Lcm Lcm_eq_0_I) | 
| 1524 | ||
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1525 | |
| 54681 | 1526 | |
| 60500 | 1527 | subsection \<open>Formal Derivatives, and the MacLaurin theorem around 0\<close> | 
| 29687 | 1528 | |
| 1529 | definition "fps_deriv f = Abs_fps (\<lambda>n. of_nat (n + 1) * f $ (n + 1))" | |
| 1530 | ||
| 54681 | 1531 | lemma fps_deriv_nth[simp]: "fps_deriv f $ n = of_nat (n +1) * f $ (n + 1)" | 
| 48757 | 1532 | by (simp add: fps_deriv_def) | 
| 1533 | ||
| 1534 | lemma fps_deriv_linear[simp]: | |
| 1535 | "fps_deriv (fps_const (a::'a::comm_semiring_1) * f + fps_const b * g) = | |
| 1536 | fps_const a * fps_deriv f + fps_const b * fps_deriv g" | |
| 36350 | 1537 | unfolding fps_eq_iff fps_add_nth fps_const_mult_left fps_deriv_nth by (simp add: field_simps) | 
| 29687 | 1538 | |
| 30488 | 1539 | lemma fps_deriv_mult[simp]: | 
| 54681 | 1540 | fixes f :: "'a::comm_ring_1 fps" | 
| 29687 | 1541 | shows "fps_deriv (f * g) = f * fps_deriv g + fps_deriv f * g" | 
| 52891 | 1542 | proof - | 
| 29687 | 1543 | let ?D = "fps_deriv" | 
| 60558 | 1544 | have "(f * ?D g + ?D f * g) $ n = ?D (f*g) $ n" for n | 
| 1545 | proof - | |
| 29687 | 1546 |     let ?Zn = "{0 ..n}"
 | 
| 1547 |     let ?Zn1 = "{0 .. n + 1}"
 | |
| 1548 | let ?g = "\<lambda>i. of_nat (i+1) * g $ (i+1) * f $ (n - i) + | |
| 1549 | of_nat (i+1)* f $ (i+1) * g $ (n - i)" | |
| 1550 | let ?h = "\<lambda>i. of_nat i * g $ i * f $ ((n+1) - i) + | |
| 1551 | of_nat i* f $ i * g $ ((n + 1) - i)" | |
| 64267 | 1552 | have s0: "sum (\<lambda>i. of_nat i * f $ i * g $ (n + 1 - i)) ?Zn1 = | 
| 1553 | sum (\<lambda>i. of_nat (n + 1 - i) * f $ (n + 1 - i) * g $ i) ?Zn1" | |
| 1554 | by (rule sum.reindex_bij_witness[where i="op - (n + 1)" and j="op - (n + 1)"]) auto | |
| 1555 | have s1: "sum (\<lambda>i. f $ i * g $ (n + 1 - i)) ?Zn1 = | |
| 1556 | sum (\<lambda>i. f $ (n + 1 - i) * g $ i) ?Zn1" | |
| 1557 | by (rule sum.reindex_bij_witness[where i="op - (n + 1)" and j="op - (n + 1)"]) auto | |
| 52891 | 1558 | have "(f * ?D g + ?D f * g)$n = (?D g * f + ?D f * g)$n" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 1559 | by (simp only: mult.commute) | 
| 29687 | 1560 | also have "\<dots> = (\<Sum>i = 0..n. ?g i)" | 
| 64267 | 1561 | by (simp add: fps_mult_nth sum.distrib[symmetric]) | 
| 1562 |     also have "\<dots> = sum ?h {0..n+1}"
 | |
| 1563 | by (rule sum.reindex_bij_witness_not_neutral | |
| 57129 
7edb7550663e
introduce more powerful reindexing rules for big operators
 hoelzl parents: 
56480diff
changeset | 1564 |             [where S'="{}" and T'="{0}" and j="Suc" and i="\<lambda>i. i - 1"]) auto
 | 
| 29687 | 1565 | also have "\<dots> = (fps_deriv (f * g)) $ n" | 
| 64267 | 1566 | apply (simp only: fps_deriv_nth fps_mult_nth sum.distrib) | 
| 29687 | 1567 | unfolding s0 s1 | 
| 64267 | 1568 | unfolding sum.distrib[symmetric] sum_distrib_left | 
| 1569 | apply (rule sum.cong) | |
| 52891 | 1570 | apply (auto simp add: of_nat_diff field_simps) | 
| 1571 | done | |
| 60558 | 1572 | finally show ?thesis . | 
| 1573 | qed | |
| 1574 | then show ?thesis | |
| 1575 | unfolding fps_eq_iff by auto | |
| 29687 | 1576 | qed | 
| 1577 | ||
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 1578 | lemma fps_deriv_X[simp]: "fps_deriv X = 1" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 1579 | by (simp add: fps_deriv_def X_def fps_eq_iff) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 1580 | |
| 54681 | 1581 | lemma fps_deriv_neg[simp]: | 
| 1582 | "fps_deriv (- (f:: 'a::comm_ring_1 fps)) = - (fps_deriv f)" | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 1583 | by (simp add: fps_eq_iff fps_deriv_def) | 
| 52891 | 1584 | |
| 54681 | 1585 | lemma fps_deriv_add[simp]: | 
| 1586 | "fps_deriv ((f:: 'a::comm_ring_1 fps) + g) = fps_deriv f + fps_deriv g" | |
| 29687 | 1587 | using fps_deriv_linear[of 1 f 1 g] by simp | 
| 1588 | ||
| 54681 | 1589 | lemma fps_deriv_sub[simp]: | 
| 1590 | "fps_deriv ((f:: 'a::comm_ring_1 fps) - g) = fps_deriv f - fps_deriv g" | |
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53374diff
changeset | 1591 | using fps_deriv_add [of f "- g"] by simp | 
| 29687 | 1592 | |
| 1593 | lemma fps_deriv_const[simp]: "fps_deriv (fps_const c) = 0" | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 1594 | by (simp add: fps_ext fps_deriv_def fps_const_def) | 
| 29687 | 1595 | |
| 48757 | 1596 | lemma fps_deriv_mult_const_left[simp]: | 
| 54681 | 1597 | "fps_deriv (fps_const (c::'a::comm_ring_1) * f) = fps_const c * fps_deriv f" | 
| 29687 | 1598 | by simp | 
| 1599 | ||
| 1600 | lemma fps_deriv_0[simp]: "fps_deriv 0 = 0" | |
| 1601 | by (simp add: fps_deriv_def fps_eq_iff) | |
| 1602 | ||
| 1603 | lemma fps_deriv_1[simp]: "fps_deriv 1 = 0" | |
| 1604 | by (simp add: fps_deriv_def fps_eq_iff ) | |
| 1605 | ||
| 48757 | 1606 | lemma fps_deriv_mult_const_right[simp]: | 
| 54681 | 1607 | "fps_deriv (f * fps_const (c::'a::comm_ring_1)) = fps_deriv f * fps_const c" | 
| 29687 | 1608 | by simp | 
| 1609 | ||
| 64267 | 1610 | lemma fps_deriv_sum: | 
| 1611 | "fps_deriv (sum f S) = sum (\<lambda>i. fps_deriv (f i :: 'a::comm_ring_1 fps)) S" | |
| 53195 | 1612 | proof (cases "finite S") | 
| 1613 | case False | |
| 1614 | then show ?thesis by simp | |
| 1615 | next | |
| 1616 | case True | |
| 1617 | show ?thesis by (induct rule: finite_induct [OF True]) simp_all | |
| 29687 | 1618 | qed | 
| 1619 | ||
| 52902 | 1620 | lemma fps_deriv_eq_0_iff [simp]: | 
| 54681 | 1621 |   "fps_deriv f = 0 \<longleftrightarrow> f = fps_const (f$0 :: 'a::{idom,semiring_char_0})"
 | 
| 60501 | 1622 | (is "?lhs \<longleftrightarrow> ?rhs") | 
| 1623 | proof | |
| 1624 | show ?lhs if ?rhs | |
| 1625 | proof - | |
| 1626 | from that have "fps_deriv f = fps_deriv (fps_const (f$0))" | |
| 1627 | by simp | |
| 1628 | then show ?thesis | |
| 1629 | by simp | |
| 1630 | qed | |
| 1631 | show ?rhs if ?lhs | |
| 1632 | proof - | |
| 1633 | from that have "\<forall>n. (fps_deriv f)$n = 0" | |
| 1634 | by simp | |
| 1635 | then have "\<forall>n. f$(n+1) = 0" | |
| 1636 | by (simp del: of_nat_Suc of_nat_add One_nat_def) | |
| 1637 | then show ?thesis | |
| 29687 | 1638 | apply (clarsimp simp add: fps_eq_iff fps_const_def) | 
| 1639 | apply (erule_tac x="n - 1" in allE) | |
| 52891 | 1640 | apply simp | 
| 1641 | done | |
| 60501 | 1642 | qed | 
| 29687 | 1643 | qed | 
| 1644 | ||
| 30488 | 1645 | lemma fps_deriv_eq_iff: | 
| 54681 | 1646 |   fixes f :: "'a::{idom,semiring_char_0} fps"
 | 
| 29687 | 1647 | shows "fps_deriv f = fps_deriv g \<longleftrightarrow> (f = fps_const(f$0 - g$0) + g)" | 
| 52891 | 1648 | proof - | 
| 52903 | 1649 | have "fps_deriv f = fps_deriv g \<longleftrightarrow> fps_deriv (f - g) = 0" | 
| 1650 | by simp | |
| 54681 | 1651 | also have "\<dots> \<longleftrightarrow> f - g = fps_const ((f - g) $ 0)" | 
| 52903 | 1652 | unfolding fps_deriv_eq_0_iff .. | 
| 60501 | 1653 | finally show ?thesis | 
| 1654 | by (simp add: field_simps) | |
| 29687 | 1655 | qed | 
| 1656 | ||
| 48757 | 1657 | lemma fps_deriv_eq_iff_ex: | 
| 54681 | 1658 |   "(fps_deriv f = fps_deriv g) \<longleftrightarrow> (\<exists>c::'a::{idom,semiring_char_0}. f = fps_const c + g)"
 | 
| 53195 | 1659 | by (auto simp: fps_deriv_eq_iff) | 
| 48757 | 1660 | |
| 1661 | ||
| 54681 | 1662 | fun fps_nth_deriv :: "nat \<Rightarrow> 'a::semiring_1 fps \<Rightarrow> 'a fps" | 
| 48757 | 1663 | where | 
| 29687 | 1664 | "fps_nth_deriv 0 f = f" | 
| 1665 | | "fps_nth_deriv (Suc n) f = fps_nth_deriv n (fps_deriv f)" | |
| 1666 | ||
| 1667 | lemma fps_nth_deriv_commute: "fps_nth_deriv (Suc n) f = fps_deriv (fps_nth_deriv n f)" | |
| 48757 | 1668 | by (induct n arbitrary: f) auto | 
| 1669 | ||
| 1670 | lemma fps_nth_deriv_linear[simp]: | |
| 1671 | "fps_nth_deriv n (fps_const (a::'a::comm_semiring_1) * f + fps_const b * g) = | |
| 1672 | fps_const a * fps_nth_deriv n f + fps_const b * fps_nth_deriv n g" | |
| 1673 | by (induct n arbitrary: f g) (auto simp add: fps_nth_deriv_commute) | |
| 1674 | ||
| 1675 | lemma fps_nth_deriv_neg[simp]: | |
| 54681 | 1676 | "fps_nth_deriv n (- (f :: 'a::comm_ring_1 fps)) = - (fps_nth_deriv n f)" | 
| 48757 | 1677 | by (induct n arbitrary: f) simp_all | 
| 1678 | ||
| 1679 | lemma fps_nth_deriv_add[simp]: | |
| 54681 | 1680 | "fps_nth_deriv n ((f :: 'a::comm_ring_1 fps) + g) = fps_nth_deriv n f + fps_nth_deriv n g" | 
| 29687 | 1681 | using fps_nth_deriv_linear[of n 1 f 1 g] by simp | 
| 1682 | ||
| 48757 | 1683 | lemma fps_nth_deriv_sub[simp]: | 
| 54681 | 1684 | "fps_nth_deriv n ((f :: 'a::comm_ring_1 fps) - g) = fps_nth_deriv n f - fps_nth_deriv n g" | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53374diff
changeset | 1685 | using fps_nth_deriv_add [of n f "- g"] by simp | 
| 29687 | 1686 | |
| 1687 | lemma fps_nth_deriv_0[simp]: "fps_nth_deriv n 0 = 0" | |
| 48757 | 1688 | by (induct n) simp_all | 
| 29687 | 1689 | |
| 1690 | lemma fps_nth_deriv_1[simp]: "fps_nth_deriv n 1 = (if n = 0 then 1 else 0)" | |
| 48757 | 1691 | by (induct n) simp_all | 
| 1692 | ||
| 1693 | lemma fps_nth_deriv_const[simp]: | |
| 1694 | "fps_nth_deriv n (fps_const c) = (if n = 0 then fps_const c else 0)" | |
| 1695 | by (cases n) simp_all | |
| 1696 | ||
| 1697 | lemma fps_nth_deriv_mult_const_left[simp]: | |
| 1698 | "fps_nth_deriv n (fps_const (c::'a::comm_ring_1) * f) = fps_const c * fps_nth_deriv n f" | |
| 29687 | 1699 | using fps_nth_deriv_linear[of n "c" f 0 0 ] by simp | 
| 1700 | ||
| 48757 | 1701 | lemma fps_nth_deriv_mult_const_right[simp]: | 
| 1702 | "fps_nth_deriv n (f * fps_const (c::'a::comm_ring_1)) = fps_nth_deriv n f * fps_const c" | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 1703 | using fps_nth_deriv_linear[of n "c" f 0 0] by (simp add: mult.commute) | 
| 29687 | 1704 | |
| 64267 | 1705 | lemma fps_nth_deriv_sum: | 
| 1706 | "fps_nth_deriv n (sum f S) = sum (\<lambda>i. fps_nth_deriv n (f i :: 'a::comm_ring_1 fps)) S" | |
| 52903 | 1707 | proof (cases "finite S") | 
| 1708 | case True | |
| 1709 | show ?thesis by (induct rule: finite_induct [OF True]) simp_all | |
| 1710 | next | |
| 1711 | case False | |
| 1712 | then show ?thesis by simp | |
| 29687 | 1713 | qed | 
| 1714 | ||
| 48757 | 1715 | lemma fps_deriv_maclauren_0: | 
| 54681 | 1716 | "(fps_nth_deriv k (f :: 'a::comm_semiring_1 fps)) $ 0 = of_nat (fact k) * f $ k" | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 1717 | by (induct k arbitrary: f) (auto simp add: field_simps) | 
| 29687 | 1718 | |
| 54681 | 1719 | |
| 60500 | 1720 | subsection \<open>Powers\<close> | 
| 29687 | 1721 | |
| 1722 | lemma fps_power_zeroth_eq_one: "a$0 =1 \<Longrightarrow> a^n $ 0 = (1::'a::semiring_1)" | |
| 48757 | 1723 | by (induct n) (auto simp add: expand_fps_eq fps_mult_nth) | 
| 29687 | 1724 | |
| 54681 | 1725 | lemma fps_power_first_eq: "(a :: 'a::comm_ring_1 fps) $ 0 =1 \<Longrightarrow> a^n $ 1 = of_nat n * a$1" | 
| 52891 | 1726 | proof (induct n) | 
| 1727 | case 0 | |
| 1728 | then show ?case by simp | |
| 29687 | 1729 | next | 
| 1730 | case (Suc n) | |
| 30488 | 1731 | show ?case unfolding power_Suc fps_mult_nth | 
| 60501 | 1732 | using Suc.hyps[OF \<open>a$0 = 1\<close>] \<open>a$0 = 1\<close> fps_power_zeroth_eq_one[OF \<open>a$0=1\<close>] | 
| 52891 | 1733 | by (simp add: field_simps) | 
| 29687 | 1734 | qed | 
| 1735 | ||
| 1736 | lemma startsby_one_power:"a $ 0 = (1::'a::comm_ring_1) \<Longrightarrow> a^n $ 0 = 1" | |
| 48757 | 1737 | by (induct n) (auto simp add: fps_mult_nth) | 
| 29687 | 1738 | |
| 1739 | lemma startsby_zero_power:"a $0 = (0::'a::comm_ring_1) \<Longrightarrow> n > 0 \<Longrightarrow> a^n $0 = 0" | |
| 48757 | 1740 | by (induct n) (auto simp add: fps_mult_nth) | 
| 29687 | 1741 | |
| 54681 | 1742 | lemma startsby_power:"a $0 = (v::'a::comm_ring_1) \<Longrightarrow> a^n $0 = v^n" | 
| 52891 | 1743 | by (induct n) (auto simp add: fps_mult_nth) | 
| 1744 | ||
| 54681 | 1745 | lemma startsby_zero_power_iff[simp]: "a^n $0 = (0::'a::idom) \<longleftrightarrow> n \<noteq> 0 \<and> a$0 = 0" | 
| 52891 | 1746 | apply (rule iffI) | 
| 1747 | apply (induct n) | |
| 1748 | apply (auto simp add: fps_mult_nth) | |
| 1749 | apply (rule startsby_zero_power, simp_all) | |
| 1750 | done | |
| 29687 | 1751 | |
| 30488 | 1752 | lemma startsby_zero_power_prefix: | 
| 60501 | 1753 | assumes a0: "a $ 0 = (0::'a::idom)" | 
| 29687 | 1754 | shows "\<forall>n < k. a ^ k $ n = 0" | 
| 30488 | 1755 | using a0 | 
| 54681 | 1756 | proof (induct k rule: nat_less_induct) | 
| 52891 | 1757 | fix k | 
| 54681 | 1758 | assume H: "\<forall>m<k. a $0 = 0 \<longrightarrow> (\<forall>n<m. a ^ m $ n = 0)" and a0: "a $ 0 = 0" | 
| 60501 | 1759 | show "\<forall>m<k. a ^ k $ m = 0" | 
| 1760 | proof (cases k) | |
| 1761 | case 0 | |
| 1762 | then show ?thesis by simp | |
| 1763 | next | |
| 1764 | case (Suc l) | |
| 1765 | have "a^k $ m = 0" if mk: "m < k" for m | |
| 1766 | proof (cases "m = 0") | |
| 1767 | case True | |
| 1768 | then show ?thesis | |
| 1769 | using startsby_zero_power[of a k] Suc a0 by simp | |
| 1770 | next | |
| 1771 | case False | |
| 1772 | have "a ^k $ m = (a^l * a) $m" | |
| 1773 | by (simp add: Suc mult.commute) | |
| 1774 | also have "\<dots> = (\<Sum>i = 0..m. a ^ l $ i * a $ (m - i))" | |
| 1775 | by (simp add: fps_mult_nth) | |
| 1776 | also have "\<dots> = 0" | |
| 64267 | 1777 | apply (rule sum.neutral) | 
| 60501 | 1778 | apply auto | 
| 1779 | apply (case_tac "x = m") | |
| 1780 | using a0 apply simp | |
| 1781 | apply (rule H[rule_format]) | |
| 1782 | using a0 Suc mk apply auto | |
| 1783 | done | |
| 1784 | finally show ?thesis . | |
| 1785 | qed | |
| 1786 | then show ?thesis by blast | |
| 1787 | qed | |
| 29687 | 1788 | qed | 
| 1789 | ||
| 64267 | 1790 | lemma startsby_zero_sum_depends: | 
| 54681 | 1791 | assumes a0: "a $0 = (0::'a::idom)" | 
| 1792 | and kn: "n \<ge> k" | |
| 64267 | 1793 |   shows "sum (\<lambda>i. (a ^ i)$k) {0 .. n} = sum (\<lambda>i. (a ^ i)$k) {0 .. k}"
 | 
| 1794 | apply (rule sum.mono_neutral_right) | |
| 54681 | 1795 | using kn | 
| 1796 | apply auto | |
| 29687 | 1797 | apply (rule startsby_zero_power_prefix[rule_format, OF a0]) | 
| 52891 | 1798 | apply arith | 
| 1799 | done | |
| 1800 | ||
| 1801 | lemma startsby_zero_power_nth_same: | |
| 54681 | 1802 | assumes a0: "a$0 = (0::'a::idom)" | 
| 29687 | 1803 | shows "a^n $ n = (a$1) ^ n" | 
| 52891 | 1804 | proof (induct n) | 
| 1805 | case 0 | |
| 52902 | 1806 | then show ?case by simp | 
| 29687 | 1807 | next | 
| 1808 | case (Suc n) | |
| 54681 | 1809 | have "a ^ Suc n $ (Suc n) = (a^n * a)$(Suc n)" | 
| 1810 | by (simp add: field_simps) | |
| 64267 | 1811 |   also have "\<dots> = sum (\<lambda>i. a^n$i * a $ (Suc n - i)) {0.. Suc n}"
 | 
| 52891 | 1812 | by (simp add: fps_mult_nth) | 
| 64267 | 1813 |   also have "\<dots> = sum (\<lambda>i. a^n$i * a $ (Suc n - i)) {n .. Suc n}"
 | 
| 1814 | apply (rule sum.mono_neutral_right) | |
| 29687 | 1815 | apply simp | 
| 1816 | apply clarsimp | |
| 1817 | apply clarsimp | |
| 1818 | apply (rule startsby_zero_power_prefix[rule_format, OF a0]) | |
| 1819 | apply arith | |
| 1820 | done | |
| 54681 | 1821 | also have "\<dots> = a^n $ n * a$1" | 
| 1822 | using a0 by simp | |
| 1823 | finally show ?case | |
| 1824 | using Suc.hyps by simp | |
| 29687 | 1825 | qed | 
| 1826 | ||
| 1827 | lemma fps_inverse_power: | |
| 54681 | 1828 | fixes a :: "'a::field fps" | 
| 29687 | 1829 | shows "inverse (a^n) = inverse a ^ n" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1830 | by (induction n) (simp_all add: fps_inverse_mult) | 
| 29687 | 1831 | |
| 48757 | 1832 | lemma fps_deriv_power: | 
| 54681 | 1833 | "fps_deriv (a ^ n) = fps_const (of_nat n :: 'a::comm_ring_1) * fps_deriv a * a ^ (n - 1)" | 
| 48757 | 1834 | apply (induct n) | 
| 52891 | 1835 | apply (auto simp add: field_simps fps_const_add[symmetric] simp del: fps_const_add) | 
| 48757 | 1836 | apply (case_tac n) | 
| 52891 | 1837 | apply (auto simp add: field_simps) | 
| 48757 | 1838 | done | 
| 29687 | 1839 | |
| 30488 | 1840 | lemma fps_inverse_deriv: | 
| 54681 | 1841 | fixes a :: "'a::field fps" | 
| 29687 | 1842 | assumes a0: "a$0 \<noteq> 0" | 
| 53077 | 1843 | shows "fps_deriv (inverse a) = - fps_deriv a * (inverse a)\<^sup>2" | 
| 54681 | 1844 | proof - | 
| 29687 | 1845 | from inverse_mult_eq_1[OF a0] | 
| 1846 | have "fps_deriv (inverse a * a) = 0" by simp | |
| 54452 | 1847 | then have "inverse a * fps_deriv a + fps_deriv (inverse a) * a = 0" | 
| 1848 | by simp | |
| 1849 | then have "inverse a * (inverse a * fps_deriv a + fps_deriv (inverse a) * a) = 0" | |
| 1850 | by simp | |
| 29687 | 1851 | with inverse_mult_eq_1[OF a0] | 
| 53077 | 1852 | have "(inverse a)\<^sup>2 * fps_deriv a + fps_deriv (inverse a) = 0" | 
| 29687 | 1853 | unfolding power2_eq_square | 
| 36350 | 1854 | apply (simp add: field_simps) | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 1855 | apply (simp add: mult.assoc[symmetric]) | 
| 52903 | 1856 | done | 
| 53077 | 1857 | then have "(inverse a)\<^sup>2 * fps_deriv a + fps_deriv (inverse a) - fps_deriv a * (inverse a)\<^sup>2 = | 
| 1858 | 0 - fps_deriv a * (inverse a)\<^sup>2" | |
| 29687 | 1859 | by simp | 
| 53077 | 1860 | then show "fps_deriv (inverse a) = - fps_deriv a * (inverse a)\<^sup>2" | 
| 52902 | 1861 | by (simp add: field_simps) | 
| 29687 | 1862 | qed | 
| 1863 | ||
| 30488 | 1864 | lemma fps_inverse_deriv': | 
| 54681 | 1865 | fixes a :: "'a::field fps" | 
| 60501 | 1866 | assumes a0: "a $ 0 \<noteq> 0" | 
| 53077 | 1867 | shows "fps_deriv (inverse a) = - fps_deriv a / a\<^sup>2" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1868 | using fps_inverse_deriv[OF a0] a0 | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1869 | by (simp add: fps_divide_unit power2_eq_square fps_inverse_mult) | 
| 29687 | 1870 | |
| 52902 | 1871 | lemma inverse_mult_eq_1': | 
| 1872 | assumes f0: "f$0 \<noteq> (0::'a::field)" | |
| 60567 | 1873 | shows "f * inverse f = 1" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 1874 | by (metis mult.commute inverse_mult_eq_1 f0) | 
| 29687 | 1875 | |
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1876 | lemma fps_inverse_minus [simp]: "inverse (-f) = -inverse (f :: 'a :: field fps)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1877 | by (cases "f$0 = 0") (auto intro: fps_inverse_unique simp: inverse_mult_eq_1' fps_inverse_eq_0) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1878 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1879 | lemma divide_fps_const [simp]: "f / fps_const (c :: 'a :: field) = fps_const (inverse c) * f" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1880 | by (cases "c = 0") (simp_all add: fps_divide_unit fps_const_inverse) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1881 | |
| 61804 
67381557cee8
Generalised derivative rule for division on formal power series
 eberlm parents: 
61799diff
changeset | 1882 | (* FIXME: The last part of this proof should go through by simp once we have a proper | 
| 
67381557cee8
Generalised derivative rule for division on formal power series
 eberlm parents: 
61799diff
changeset | 1883 | theorem collection for simplifying division on rings *) | 
| 52902 | 1884 | lemma fps_divide_deriv: | 
| 61804 
67381557cee8
Generalised derivative rule for division on formal power series
 eberlm parents: 
61799diff
changeset | 1885 | assumes "b dvd (a :: 'a :: field fps)" | 
| 
67381557cee8
Generalised derivative rule for division on formal power series
 eberlm parents: 
61799diff
changeset | 1886 | shows "fps_deriv (a / b) = (fps_deriv a * b - a * fps_deriv b) / b^2" | 
| 
67381557cee8
Generalised derivative rule for division on formal power series
 eberlm parents: 
61799diff
changeset | 1887 | proof - | 
| 
67381557cee8
Generalised derivative rule for division on formal power series
 eberlm parents: 
61799diff
changeset | 1888 | have eq_divide_imp: "c \<noteq> 0 \<Longrightarrow> a * c = b \<Longrightarrow> a = b div c" for a b c :: "'a :: field fps" | 
| 
67381557cee8
Generalised derivative rule for division on formal power series
 eberlm parents: 
61799diff
changeset | 1889 | by (drule sym) (simp add: mult.assoc) | 
| 
67381557cee8
Generalised derivative rule for division on formal power series
 eberlm parents: 
61799diff
changeset | 1890 | from assms have "a = a / b * b" by simp | 
| 
67381557cee8
Generalised derivative rule for division on formal power series
 eberlm parents: 
61799diff
changeset | 1891 | also have "fps_deriv (a / b * b) = fps_deriv (a / b) * b + a / b * fps_deriv b" by simp | 
| 
67381557cee8
Generalised derivative rule for division on formal power series
 eberlm parents: 
61799diff
changeset | 1892 | finally have "fps_deriv (a / b) * b^2 = fps_deriv a * b - a * fps_deriv b" using assms | 
| 
67381557cee8
Generalised derivative rule for division on formal power series
 eberlm parents: 
61799diff
changeset | 1893 | by (simp add: power2_eq_square algebra_simps) | 
| 
67381557cee8
Generalised derivative rule for division on formal power series
 eberlm parents: 
61799diff
changeset | 1894 | thus ?thesis by (cases "b = 0") (auto simp: eq_divide_imp) | 
| 
67381557cee8
Generalised derivative rule for division on formal power series
 eberlm parents: 
61799diff
changeset | 1895 | qed | 
| 29687 | 1896 | |
| 54681 | 1897 | lemma fps_inverse_gp': "inverse (Abs_fps (\<lambda>n. 1::'a::field)) = 1 - X" | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 1898 | by (simp add: fps_inverse_gp fps_eq_iff X_def) | 
| 29687 | 1899 | |
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1900 | lemma fps_one_over_one_minus_X_squared: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1901 | "inverse ((1 - X)^2 :: 'a :: field fps) = Abs_fps (\<lambda>n. of_nat (n+1))" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1902 | proof - | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1903 | have "inverse ((1 - X)^2 :: 'a fps) = fps_deriv (inverse (1 - X))" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1904 | by (subst fps_inverse_deriv) (simp_all add: fps_inverse_power) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1905 | also have "inverse (1 - X :: 'a fps) = Abs_fps (\<lambda>_. 1)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1906 | by (subst fps_inverse_gp' [symmetric]) simp | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1907 | also have "fps_deriv \<dots> = Abs_fps (\<lambda>n. of_nat (n + 1))" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1908 | by (simp add: fps_deriv_def) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1909 | finally show ?thesis . | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1910 | qed | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 1911 | |
| 29687 | 1912 | lemma fps_nth_deriv_X[simp]: "fps_nth_deriv n X = (if n = 0 then X else if n=1 then 1 else 0)" | 
| 52902 | 1913 | by (cases n) simp_all | 
| 29687 | 1914 | |
| 60501 | 1915 | lemma fps_inverse_X_plus1: "inverse (1 + X) = Abs_fps (\<lambda>n. (- (1::'a::field)) ^ n)" | 
| 1916 | (is "_ = ?r") | |
| 54681 | 1917 | proof - | 
| 29687 | 1918 | have eq: "(1 + X) * ?r = 1" | 
| 1919 | unfolding minus_one_power_iff | |
| 36350 | 1920 | by (auto simp add: field_simps fps_eq_iff) | 
| 54681 | 1921 | show ?thesis | 
| 1922 | by (auto simp add: eq intro: fps_inverse_unique) | |
| 29687 | 1923 | qed | 
| 1924 | ||
| 30488 | 1925 | |
| 60501 | 1926 | subsection \<open>Integration\<close> | 
| 31273 | 1927 | |
| 52903 | 1928 | definition fps_integral :: "'a::field_char_0 fps \<Rightarrow> 'a \<Rightarrow> 'a fps" | 
| 1929 | where "fps_integral a a0 = Abs_fps (\<lambda>n. if n = 0 then a0 else (a$(n - 1) / of_nat n))" | |
| 29687 | 1930 | |
| 31273 | 1931 | lemma fps_deriv_fps_integral: "fps_deriv (fps_integral a a0) = a" | 
| 1932 | unfolding fps_integral_def fps_deriv_def | |
| 1933 | by (simp add: fps_eq_iff del: of_nat_Suc) | |
| 29687 | 1934 | |
| 31273 | 1935 | lemma fps_integral_linear: | 
| 1936 | "fps_integral (fps_const a * f + fps_const b * g) (a*a0 + b*b0) = | |
| 1937 | fps_const a * fps_integral f a0 + fps_const b * fps_integral g b0" | |
| 1938 | (is "?l = ?r") | |
| 53195 | 1939 | proof - | 
| 54681 | 1940 | have "fps_deriv ?l = fps_deriv ?r" | 
| 1941 | by (simp add: fps_deriv_fps_integral) | |
| 1942 | moreover have "?l$0 = ?r$0" | |
| 1943 | by (simp add: fps_integral_def) | |
| 29687 | 1944 | ultimately show ?thesis | 
| 1945 | unfolding fps_deriv_eq_iff by auto | |
| 1946 | qed | |
| 30488 | 1947 | |
| 53195 | 1948 | |
| 60500 | 1949 | subsection \<open>Composition of FPSs\<close> | 
| 53195 | 1950 | |
| 60501 | 1951 | definition fps_compose :: "'a::semiring_1 fps \<Rightarrow> 'a fps \<Rightarrow> 'a fps" (infixl "oo" 55) | 
| 64267 | 1952 |   where "a oo b = Abs_fps (\<lambda>n. sum (\<lambda>i. a$i * (b^i$n)) {0..n})"
 | 
| 1953 | ||
| 1954 | lemma fps_compose_nth: "(a oo b)$n = sum (\<lambda>i. a$i * (b^i$n)) {0..n}"
 | |
| 48757 | 1955 | by (simp add: fps_compose_def) | 
| 29687 | 1956 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1957 | lemma fps_compose_nth_0 [simp]: "(f oo g) $ 0 = f $ 0" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1958 | by (simp add: fps_compose_nth) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 1959 | |
| 54681 | 1960 | lemma fps_compose_X[simp]: "a oo X = (a :: 'a::comm_ring_1 fps)" | 
| 64267 | 1961 | by (simp add: fps_ext fps_compose_def mult_delta_right sum.delta') | 
| 30488 | 1962 | |
| 60501 | 1963 | lemma fps_const_compose[simp]: "fps_const (a::'a::comm_ring_1) oo b = fps_const a" | 
| 64267 | 1964 | by (simp add: fps_eq_iff fps_compose_nth mult_delta_left sum.delta) | 
| 29687 | 1965 | |
| 54681 | 1966 | lemma numeral_compose[simp]: "(numeral k :: 'a::comm_ring_1 fps) oo b = numeral k" | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 1967 | unfolding numeral_fps_const by simp | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 1968 | |
| 54681 | 1969 | lemma neg_numeral_compose[simp]: "(- numeral k :: 'a::comm_ring_1 fps) oo b = - numeral k" | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 1970 | unfolding neg_numeral_fps_const by simp | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 1971 | |
| 54681 | 1972 | lemma X_fps_compose_startby0[simp]: "a$0 = 0 \<Longrightarrow> X oo a = (a :: 'a::comm_ring_1 fps)" | 
| 64267 | 1973 | by (simp add: fps_eq_iff fps_compose_def mult_delta_left sum.delta not_le) | 
| 29687 | 1974 | |
| 1975 | ||
| 60500 | 1976 | subsection \<open>Rules from Herbert Wilf's Generatingfunctionology\<close> | 
| 1977 | ||
| 1978 | subsubsection \<open>Rule 1\<close> | |
| 64267 | 1979 |   (* {a_{n+k}}_0^infty Corresponds to (f - sum (\<lambda>i. a_i * x^i))/x^h, for h>0*)
 | 
| 29687 | 1980 | |
| 30488 | 1981 | lemma fps_power_mult_eq_shift: | 
| 52902 | 1982 | "X^Suc k * Abs_fps (\<lambda>n. a (n + Suc k)) = | 
| 64267 | 1983 |     Abs_fps a - sum (\<lambda>i. fps_const (a i :: 'a::comm_ring_1) * X^i) {0 .. k}"
 | 
| 52902 | 1984 | (is "?lhs = ?rhs") | 
| 1985 | proof - | |
| 60501 | 1986 | have "?lhs $ n = ?rhs $ n" for n :: nat | 
| 1987 | proof - | |
| 30488 | 1988 | have "?lhs $ n = (if n < Suc k then 0 else a n)" | 
| 29687 | 1989 | unfolding X_power_mult_nth by auto | 
| 1990 | also have "\<dots> = ?rhs $ n" | |
| 52902 | 1991 | proof (induct k) | 
| 1992 | case 0 | |
| 60501 | 1993 | then show ?case | 
| 64267 | 1994 | by (simp add: fps_sum_nth) | 
| 29687 | 1995 | next | 
| 1996 | case (Suc k) | |
| 64267 | 1997 |       have "(Abs_fps a - sum (\<lambda>i. fps_const (a i :: 'a) * X^i) {0 .. Suc k})$n =
 | 
| 1998 |         (Abs_fps a - sum (\<lambda>i. fps_const (a i :: 'a) * X^i) {0 .. k} -
 | |
| 53196 | 1999 | fps_const (a (Suc k)) * X^ Suc k) $ n" | 
| 52902 | 2000 | by (simp add: field_simps) | 
| 2001 | also have "\<dots> = (if n < Suc k then 0 else a n) - (fps_const (a (Suc k)) * X^ Suc k)$n" | |
| 60501 | 2002 | using Suc.hyps[symmetric] unfolding fps_sub_nth by simp | 
| 29687 | 2003 | also have "\<dots> = (if n < Suc (Suc k) then 0 else a n)" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2004 | unfolding X_power_mult_right_nth | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2005 | apply (auto simp add: not_less fps_const_def) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2006 | apply (rule cong[of a a, OF refl]) | 
| 52902 | 2007 | apply arith | 
| 2008 | done | |
| 60501 | 2009 | finally show ?case | 
| 2010 | by simp | |
| 29687 | 2011 | qed | 
| 60501 | 2012 | finally show ?thesis . | 
| 2013 | qed | |
| 2014 | then show ?thesis | |
| 2015 | by (simp add: fps_eq_iff) | |
| 29687 | 2016 | qed | 
| 2017 | ||
| 53195 | 2018 | |
| 60500 | 2019 | subsubsection \<open>Rule 2\<close> | 
| 29687 | 2020 | |
| 2021 | (* We can not reach the form of Wilf, but still near to it using rewrite rules*) | |
| 30488 | 2022 |   (* If f reprents {a_n} and P is a polynomial, then
 | 
| 29687 | 2023 |         P(xD) f represents {P(n) a_n}*)
 | 
| 2024 | ||
| 54681 | 2025 | definition "XD = op * X \<circ> fps_deriv" | 
| 2026 | ||
| 2027 | lemma XD_add[simp]:"XD (a + b) = XD a + XD (b :: 'a::comm_ring_1 fps)" | |
| 36350 | 2028 | by (simp add: XD_def field_simps) | 
| 29687 | 2029 | |
| 2030 | lemma XD_mult_const[simp]:"XD (fps_const (c::'a::comm_ring_1) * a) = fps_const c * XD a" | |
| 36350 | 2031 | by (simp add: XD_def field_simps) | 
| 29687 | 2032 | |
| 52902 | 2033 | lemma XD_linear[simp]: "XD (fps_const c * a + fps_const d * b) = | 
| 54681 | 2034 | fps_const c * XD a + fps_const d * XD (b :: 'a::comm_ring_1 fps)" | 
| 29687 | 2035 | by simp | 
| 2036 | ||
| 30952 
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
 haftmann parents: 
30837diff
changeset | 2037 | lemma XDN_linear: | 
| 52902 | 2038 | "(XD ^^ n) (fps_const c * a + fps_const d * b) = | 
| 54681 | 2039 | fps_const c * (XD ^^ n) a + fps_const d * (XD ^^ n) (b :: 'a::comm_ring_1 fps)" | 
| 48757 | 2040 | by (induct n) simp_all | 
| 29687 | 2041 | |
| 52902 | 2042 | lemma fps_mult_X_deriv_shift: "X* fps_deriv a = Abs_fps (\<lambda>n. of_nat n* a$n)" | 
| 2043 | by (simp add: fps_eq_iff) | |
| 29687 | 2044 | |
| 30952 
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
 haftmann parents: 
30837diff
changeset | 2045 | lemma fps_mult_XD_shift: | 
| 54681 | 2046 | "(XD ^^ k) (a :: 'a::comm_ring_1 fps) = Abs_fps (\<lambda>n. (of_nat n ^ k) * a$n)" | 
| 52902 | 2047 | by (induct k arbitrary: a) (simp_all add: XD_def fps_eq_iff field_simps del: One_nat_def) | 
| 29687 | 2048 | |
| 53195 | 2049 | |
| 60501 | 2050 | subsubsection \<open>Rule 3\<close> | 
| 2051 | ||
| 61585 | 2052 | text \<open>Rule 3 is trivial and is given by \<open>fps_times_def\<close>.\<close> | 
| 60501 | 2053 | |
| 60500 | 2054 | |
| 2055 | subsubsection \<open>Rule 5 --- summation and "division" by (1 - X)\<close> | |
| 29687 | 2056 | |
| 64267 | 2057 | lemma fps_divide_X_minus1_sum_lemma: | 
| 2058 |   "a = ((1::'a::comm_ring_1 fps) - X) * Abs_fps (\<lambda>n. sum (\<lambda>i. a $ i) {0..n})"
 | |
| 53195 | 2059 | proof - | 
| 64267 | 2060 |   let ?sa = "Abs_fps (\<lambda>n. sum (\<lambda>i. a $ i) {0..n})"
 | 
| 52902 | 2061 | have th0: "\<And>i. (1 - (X::'a fps)) $ i = (if i = 0 then 1 else if i = 1 then - 1 else 0)" | 
| 2062 | by simp | |
| 60501 | 2063 | have "a$n = ((1 - X) * ?sa) $ n" for n | 
| 2064 | proof (cases "n = 0") | |
| 2065 | case True | |
| 2066 | then show ?thesis | |
| 2067 | by (simp add: fps_mult_nth) | |
| 2068 | next | |
| 2069 | case False | |
| 2070 |     then have u: "{0} \<union> ({1} \<union> {2..n}) = {0..n}" "{1} \<union> {2..n} = {1..n}"
 | |
| 2071 |       "{0..n - 1} \<union> {n} = {0..n}"
 | |
| 2072 | by (auto simp: set_eq_iff) | |
| 2073 |     have d: "{0} \<inter> ({1} \<union> {2..n}) = {}" "{1} \<inter> {2..n} = {}" "{0..n - 1} \<inter> {n} = {}"
 | |
| 2074 | using False by simp_all | |
| 2075 |     have f: "finite {0}" "finite {1}" "finite {2 .. n}"
 | |
| 2076 |       "finite {0 .. n - 1}" "finite {n}" by simp_all
 | |
| 64267 | 2077 |     have "((1 - X) * ?sa) $ n = sum (\<lambda>i. (1 - X)$ i * ?sa $ (n - i)) {0 .. n}"
 | 
| 60501 | 2078 | by (simp add: fps_mult_nth) | 
| 2079 | also have "\<dots> = a$n" | |
| 2080 | unfolding th0 | |
| 64267 | 2081 | unfolding sum.union_disjoint[OF f(1) finite_UnI[OF f(2,3)] d(1), unfolded u(1)] | 
| 2082 | unfolding sum.union_disjoint[OF f(2) f(3) d(2)] | |
| 60501 | 2083 | apply (simp) | 
| 64267 | 2084 | unfolding sum.union_disjoint[OF f(4,5) d(3), unfolded u(3)] | 
| 60501 | 2085 | apply simp | 
| 2086 | done | |
| 2087 | finally show ?thesis | |
| 2088 | by simp | |
| 2089 | qed | |
| 54681 | 2090 | then show ?thesis | 
| 2091 | unfolding fps_eq_iff by blast | |
| 29687 | 2092 | qed | 
| 2093 | ||
| 64267 | 2094 | lemma fps_divide_X_minus1_sum: | 
| 2095 |   "a /((1::'a::field fps) - X) = Abs_fps (\<lambda>n. sum (\<lambda>i. a $ i) {0..n})"
 | |
| 52902 | 2096 | proof - | 
| 54681 | 2097 | let ?X = "1 - (X::'a fps)" | 
| 2098 | have th0: "?X $ 0 \<noteq> 0" | |
| 2099 | by simp | |
| 64267 | 2100 |   have "a /?X = ?X *  Abs_fps (\<lambda>n::nat. sum (op $ a) {0..n}) * inverse ?X"
 | 
| 2101 | using fps_divide_X_minus1_sum_lemma[of a, symmetric] th0 | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 2102 | by (simp add: fps_divide_def mult.assoc) | 
| 64267 | 2103 |   also have "\<dots> = (inverse ?X * ?X) * Abs_fps (\<lambda>n::nat. sum (op $ a) {0..n}) "
 | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 2104 | by (simp add: ac_simps) | 
| 54681 | 2105 | finally show ?thesis | 
| 2106 | by (simp add: inverse_mult_eq_1[OF th0]) | |
| 29687 | 2107 | qed | 
| 2108 | ||
| 53195 | 2109 | |
| 60501 | 2110 | subsubsection \<open>Rule 4 in its more general form: generalizes Rule 3 for an arbitrary | 
| 60500 | 2111 | finite product of FPS, also the relvant instance of powers of a FPS\<close> | 
| 29687 | 2112 | |
| 63882 
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
 nipkow parents: 
63589diff
changeset | 2113 | definition "natpermute n k = {l :: nat list. length l = k \<and> sum_list l = n}"
 | 
| 29687 | 2114 | |
| 2115 | lemma natlist_trivial_1: "natpermute n 1 = {[n]}"
 | |
| 2116 | apply (auto simp add: natpermute_def) | |
| 52902 | 2117 | apply (case_tac x) | 
| 2118 | apply auto | |
| 29687 | 2119 | done | 
| 2120 | ||
| 2121 | lemma append_natpermute_less_eq: | |
| 54452 | 2122 | assumes "xs @ ys \<in> natpermute n k" | 
| 63882 
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
 nipkow parents: 
63589diff
changeset | 2123 | shows "sum_list xs \<le> n" | 
| 
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
 nipkow parents: 
63589diff
changeset | 2124 | and "sum_list ys \<le> n" | 
| 52902 | 2125 | proof - | 
| 63882 
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
 nipkow parents: 
63589diff
changeset | 2126 | from assms have "sum_list (xs @ ys) = n" | 
| 54452 | 2127 | by (simp add: natpermute_def) | 
| 63882 
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
 nipkow parents: 
63589diff
changeset | 2128 | then have "sum_list xs + sum_list ys = n" | 
| 54452 | 2129 | by simp | 
| 63882 
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
 nipkow parents: 
63589diff
changeset | 2130 | then show "sum_list xs \<le> n" and "sum_list ys \<le> n" | 
| 54452 | 2131 | by simp_all | 
| 29687 | 2132 | qed | 
| 2133 | ||
| 2134 | lemma natpermute_split: | |
| 54452 | 2135 | assumes "h \<le> k" | 
| 52902 | 2136 | shows "natpermute n k = | 
| 2137 |     (\<Union>m \<in>{0..n}. {l1 @ l2 |l1 l2. l1 \<in> natpermute m h \<and> l2 \<in> natpermute (n - m) (k - h)})"
 | |
| 60558 | 2138 |   (is "?L = ?R" is "_ = (\<Union>m \<in>{0..n}. ?S m)")
 | 
| 2139 | proof | |
| 2140 | show "?R \<subseteq> ?L" | |
| 2141 | proof | |
| 52902 | 2142 | fix l | 
| 2143 | assume l: "l \<in> ?R" | |
| 2144 |     from l obtain m xs ys where h: "m \<in> {0..n}"
 | |
| 2145 | and xs: "xs \<in> natpermute m h" | |
| 2146 | and ys: "ys \<in> natpermute (n - m) (k - h)" | |
| 2147 | and leq: "l = xs@ys" by blast | |
| 63882 
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
 nipkow parents: 
63589diff
changeset | 2148 | from xs have xs': "sum_list xs = m" | 
| 52902 | 2149 | by (simp add: natpermute_def) | 
| 63882 
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
 nipkow parents: 
63589diff
changeset | 2150 | from ys have ys': "sum_list ys = n - m" | 
| 52902 | 2151 | by (simp add: natpermute_def) | 
| 60558 | 2152 | show "l \<in> ?L" using leq xs ys h | 
| 46131 | 2153 | apply (clarsimp simp add: natpermute_def) | 
| 29687 | 2154 | unfolding xs' ys' | 
| 54452 | 2155 | using assms xs ys | 
| 48757 | 2156 | unfolding natpermute_def | 
| 2157 | apply simp | |
| 2158 | done | |
| 60558 | 2159 | qed | 
| 2160 | show "?L \<subseteq> ?R" | |
| 2161 | proof | |
| 52902 | 2162 | fix l | 
| 2163 | assume l: "l \<in> natpermute n k" | |
| 29687 | 2164 | let ?xs = "take h l" | 
| 2165 | let ?ys = "drop h l" | |
| 63882 
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
 nipkow parents: 
63589diff
changeset | 2166 | let ?m = "sum_list ?xs" | 
| 
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
 nipkow parents: 
63589diff
changeset | 2167 | from l have ls: "sum_list (?xs @ ?ys) = n" | 
| 52902 | 2168 | by (simp add: natpermute_def) | 
| 54452 | 2169 | have xs: "?xs \<in> natpermute ?m h" using l assms | 
| 52902 | 2170 | by (simp add: natpermute_def) | 
| 63882 
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
 nipkow parents: 
63589diff
changeset | 2171 | have l_take_drop: "sum_list l = sum_list (take h l @ drop h l)" | 
| 52902 | 2172 | by simp | 
| 2173 | then have ys: "?ys \<in> natpermute (n - ?m) (k - h)" | |
| 54452 | 2174 | using l assms ls by (auto simp add: natpermute_def simp del: append_take_drop_id) | 
| 52902 | 2175 |     from ls have m: "?m \<in> {0..n}"
 | 
| 2176 | by (simp add: l_take_drop del: append_take_drop_id) | |
| 60558 | 2177 | from xs ys ls show "l \<in> ?R" | 
| 29687 | 2178 | apply auto | 
| 52902 | 2179 | apply (rule bexI [where x = "?m"]) | 
| 2180 | apply (rule exI [where x = "?xs"]) | |
| 2181 | apply (rule exI [where x = "?ys"]) | |
| 52891 | 2182 | using ls l | 
| 46131 | 2183 | apply (auto simp add: natpermute_def l_take_drop simp del: append_take_drop_id) | 
| 48757 | 2184 | apply simp | 
| 2185 | done | |
| 60558 | 2186 | qed | 
| 29687 | 2187 | qed | 
| 2188 | ||
| 2189 | lemma natpermute_0: "natpermute n 0 = (if n = 0 then {[]} else {})"
 | |
| 2190 | by (auto simp add: natpermute_def) | |
| 52902 | 2191 | |
| 29687 | 2192 | lemma natpermute_0'[simp]: "natpermute 0 k = (if k = 0 then {[]} else {replicate k 0})"
 | 
| 2193 | apply (auto simp add: set_replicate_conv_if natpermute_def) | |
| 2194 | apply (rule nth_equalityI) | |
| 48757 | 2195 | apply simp_all | 
| 2196 | done | |
| 29687 | 2197 | |
| 2198 | lemma natpermute_finite: "finite (natpermute n k)" | |
| 52902 | 2199 | proof (induct k arbitrary: n) | 
| 2200 | case 0 | |
| 2201 | then show ?case | |
| 29687 | 2202 | apply (subst natpermute_split[of 0 0, simplified]) | 
| 52902 | 2203 | apply (simp add: natpermute_0) | 
| 2204 | done | |
| 29687 | 2205 | next | 
| 2206 | case (Suc k) | |
| 52902 | 2207 | then show ?case unfolding natpermute_split [of k "Suc k", simplified] | 
| 29687 | 2208 | apply - | 
| 2209 | apply (rule finite_UN_I) | |
| 2210 | apply simp | |
| 2211 | unfolding One_nat_def[symmetric] natlist_trivial_1 | |
| 2212 | apply simp | |
| 2213 | done | |
| 2214 | qed | |
| 2215 | ||
| 2216 | lemma natpermute_contain_maximal: | |
| 60558 | 2217 |   "{xs \<in> natpermute n (k + 1). n \<in> set xs} = (\<Union>i\<in>{0 .. k}. {(replicate (k + 1) 0) [i:=n]})"
 | 
| 29687 | 2218 | (is "?A = ?B") | 
| 60558 | 2219 | proof | 
| 2220 | show "?A \<subseteq> ?B" | |
| 2221 | proof | |
| 52902 | 2222 | fix xs | 
| 60558 | 2223 | assume "xs \<in> ?A" | 
| 2224 | then have H: "xs \<in> natpermute n (k + 1)" and n: "n \<in> set xs" | |
| 2225 | by blast+ | |
| 2226 |     then obtain i where i: "i \<in> {0.. k}" "xs!i = n"
 | |
| 30488 | 2227 | unfolding in_set_conv_nth by (auto simp add: less_Suc_eq_le natpermute_def) | 
| 52902 | 2228 |     have eqs: "({0..k} - {i}) \<union> {i} = {0..k}"
 | 
| 2229 | using i by auto | |
| 2230 |     have f: "finite({0..k} - {i})" "finite {i}"
 | |
| 2231 | by auto | |
| 2232 |     have d: "({0..k} - {i}) \<inter> {i} = {}"
 | |
| 2233 | using i by auto | |
| 64267 | 2234 |     from H have "n = sum (nth xs) {0..k}"
 | 
| 52902 | 2235 | apply (simp add: natpermute_def) | 
| 64267 | 2236 | apply (auto simp add: atLeastLessThanSuc_atLeastAtMost sum_list_sum_nth) | 
| 52902 | 2237 | done | 
| 64267 | 2238 |     also have "\<dots> = n + sum (nth xs) ({0..k} - {i})"
 | 
| 2239 | unfolding sum.union_disjoint[OF f d, unfolded eqs] using i by simp | |
| 52902 | 2240 |     finally have zxs: "\<forall> j\<in> {0..k} - {i}. xs!j = 0"
 | 
| 2241 | by auto | |
| 2242 | from H have xsl: "length xs = k+1" | |
| 2243 | by (simp add: natpermute_def) | |
| 29687 | 2244 | from i have i': "i < length (replicate (k+1) 0)" "i < k+1" | 
| 52902 | 2245 | unfolding length_replicate by presburger+ | 
| 29687 | 2246 | have "xs = replicate (k+1) 0 [i := n]" | 
| 2247 | apply (rule nth_equalityI) | |
| 2248 | unfolding xsl length_list_update length_replicate | |
| 2249 | apply simp | |
| 2250 | apply clarify | |
| 2251 | unfolding nth_list_update[OF i'(1)] | |
| 2252 | using i zxs | |
| 52902 | 2253 | apply (case_tac "ia = i") | 
| 2254 | apply (auto simp del: replicate.simps) | |
| 2255 | done | |
| 60558 | 2256 | then show "xs \<in> ?B" using i by blast | 
| 2257 | qed | |
| 2258 | show "?B \<subseteq> ?A" | |
| 2259 | proof | |
| 2260 | fix xs | |
| 2261 | assume "xs \<in> ?B" | |
| 2262 |     then obtain i where i: "i \<in> {0..k}" and xs: "xs = replicate (k + 1) 0 [i:=n]"
 | |
| 2263 | by auto | |
| 2264 | have nxs: "n \<in> set xs" | |
| 2265 | unfolding xs | |
| 52902 | 2266 | apply (rule set_update_memI) | 
| 2267 | using i apply simp | |
| 2268 | done | |
| 60558 | 2269 | have xsl: "length xs = k + 1" | 
| 2270 | by (simp only: xs length_replicate length_list_update) | |
| 64267 | 2271 |     have "sum_list xs = sum (nth xs) {0..<k+1}"
 | 
| 2272 | unfolding sum_list_sum_nth xsl .. | |
| 2273 |     also have "\<dots> = sum (\<lambda>j. if j = i then n else 0) {0..< k+1}"
 | |
| 2274 | by (rule sum.cong) (simp_all add: xs del: replicate.simps) | |
| 2275 | also have "\<dots> = n" using i by (simp add: sum.delta) | |
| 60558 | 2276 | finally have "xs \<in> natpermute n (k + 1)" | 
| 52902 | 2277 | using xsl unfolding natpermute_def mem_Collect_eq by blast | 
| 60558 | 2278 | then show "xs \<in> ?A" | 
| 2279 | using nxs by blast | |
| 2280 | qed | |
| 29687 | 2281 | qed | 
| 2282 | ||
| 60558 | 2283 | text \<open>The general form.\<close> | 
| 64272 | 2284 | lemma fps_prod_nth: | 
| 52902 | 2285 | fixes m :: nat | 
| 54681 | 2286 | and a :: "nat \<Rightarrow> 'a::comm_ring_1 fps" | 
| 64272 | 2287 |   shows "(prod a {0 .. m}) $ n =
 | 
| 2288 |     sum (\<lambda>v. prod (\<lambda>j. (a j) $ (v!j)) {0..m}) (natpermute n (m+1))"
 | |
| 29687 | 2289 | (is "?P m n") | 
| 52902 | 2290 | proof (induct m arbitrary: n rule: nat_less_induct) | 
| 29687 | 2291 | fix m n assume H: "\<forall>m' < m. \<forall>n. ?P m' n" | 
| 53196 | 2292 | show "?P m n" | 
| 2293 | proof (cases m) | |
| 2294 | case 0 | |
| 2295 | then show ?thesis | |
| 2296 | apply simp | |
| 2297 | unfolding natlist_trivial_1[where n = n, unfolded One_nat_def] | |
| 2298 | apply simp | |
| 2299 | done | |
| 2300 | next | |
| 2301 | case (Suc k) | |
| 2302 | then have km: "k < m" by arith | |
| 52902 | 2303 |     have u0: "{0 .. k} \<union> {m} = {0..m}"
 | 
| 54452 | 2304 | using Suc by (simp add: set_eq_iff) presburger | 
| 29687 | 2305 |     have f0: "finite {0 .. k}" "finite {m}" by auto
 | 
| 53196 | 2306 |     have d0: "{0 .. k} \<inter> {m} = {}" using Suc by auto
 | 
| 64272 | 2307 |     have "(prod a {0 .. m}) $ n = (prod a {0 .. k} * a m) $ n"
 | 
| 2308 | unfolding prod.union_disjoint[OF f0 d0, unfolded u0] by simp | |
| 29687 | 2309 |     also have "\<dots> = (\<Sum>i = 0..n. (\<Sum>v\<in>natpermute i (k + 1). \<Prod>j\<in>{0..k}. a j $ v ! j) * a m $ (n - i))"
 | 
| 2310 | unfolding fps_mult_nth H[rule_format, OF km] .. | |
| 2311 |     also have "\<dots> = (\<Sum>v\<in>natpermute n (m + 1). \<Prod>j\<in>{0..m}. a j $ v ! j)"
 | |
| 53196 | 2312 | apply (simp add: Suc) | 
| 48757 | 2313 | unfolding natpermute_split[of m "m + 1", simplified, of n, | 
| 53196 | 2314 | unfolded natlist_trivial_1[unfolded One_nat_def] Suc] | 
| 64267 | 2315 | apply (subst sum.UNION_disjoint) | 
| 30488 | 2316 | apply simp | 
| 29687 | 2317 | apply simp | 
| 2318 | unfolding image_Collect[symmetric] | |
| 2319 | apply clarsimp | |
| 2320 | apply (rule finite_imageI) | |
| 2321 | apply (rule natpermute_finite) | |
| 39302 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 nipkow parents: 
39198diff
changeset | 2322 | apply (clarsimp simp add: set_eq_iff) | 
| 29687 | 2323 | apply auto | 
| 64267 | 2324 | apply (rule sum.cong) | 
| 57418 | 2325 | apply (rule refl) | 
| 64267 | 2326 | unfolding sum_distrib_right | 
| 29687 | 2327 | apply (rule sym) | 
| 64267 | 2328 | apply (rule_tac l = "\<lambda>xs. xs @ [n - x]" in sum.reindex_cong) | 
| 29687 | 2329 | apply (simp add: inj_on_def) | 
| 2330 | apply auto | |
| 64272 | 2331 | unfolding prod.union_disjoint[OF f0 d0, unfolded u0, unfolded Suc] | 
| 29687 | 2332 | apply (clarsimp simp add: natpermute_def nth_append) | 
| 2333 | done | |
| 53196 | 2334 | finally show ?thesis . | 
| 2335 | qed | |
| 29687 | 2336 | qed | 
| 2337 | ||
| 60558 | 2338 | text \<open>The special form for powers.\<close> | 
| 29687 | 2339 | lemma fps_power_nth_Suc: | 
| 52903 | 2340 | fixes m :: nat | 
| 54681 | 2341 | and a :: "'a::comm_ring_1 fps" | 
| 64272 | 2342 |   shows "(a ^ Suc m)$n = sum (\<lambda>v. prod (\<lambda>j. a $ (v!j)) {0..m}) (natpermute n (m+1))"
 | 
| 52902 | 2343 | proof - | 
| 64272 | 2344 |   have th0: "a^Suc m = prod (\<lambda>i. a) {0..m}"
 | 
| 2345 | by (simp add: prod_constant) | |
| 2346 | show ?thesis unfolding th0 fps_prod_nth .. | |
| 29687 | 2347 | qed | 
| 52902 | 2348 | |
| 29687 | 2349 | lemma fps_power_nth: | 
| 54452 | 2350 | fixes m :: nat | 
| 54681 | 2351 | and a :: "'a::comm_ring_1 fps" | 
| 53196 | 2352 | shows "(a ^m)$n = | 
| 64272 | 2353 |     (if m=0 then 1$n else sum (\<lambda>v. prod (\<lambda>j. a $ (v!j)) {0..m - 1}) (natpermute n m))"
 | 
| 52902 | 2354 | by (cases m) (simp_all add: fps_power_nth_Suc del: power_Suc) | 
| 29687 | 2355 | |
| 30488 | 2356 | lemma fps_nth_power_0: | 
| 54452 | 2357 | fixes m :: nat | 
| 54681 | 2358 | and a :: "'a::comm_ring_1 fps" | 
| 29687 | 2359 | shows "(a ^m)$0 = (a$0) ^ m" | 
| 53195 | 2360 | proof (cases m) | 
| 2361 | case 0 | |
| 2362 | then show ?thesis by simp | |
| 2363 | next | |
| 2364 | case (Suc n) | |
| 2365 |   then have c: "m = card {0..n}" by simp
 | |
| 64272 | 2366 |   have "(a ^m)$0 = prod (\<lambda>i. a$0) {0..n}"
 | 
| 53195 | 2367 | by (simp add: Suc fps_power_nth del: replicate.simps power_Suc) | 
| 2368 | also have "\<dots> = (a$0) ^ m" | |
| 64272 | 2369 | unfolding c by (rule prod_constant) | 
| 53195 | 2370 | finally show ?thesis . | 
| 29687 | 2371 | qed | 
| 2372 | ||
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2373 | lemma natpermute_max_card: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2374 | assumes n0: "n \<noteq> 0" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2375 |   shows "card {xs \<in> natpermute n (k + 1). n \<in> set xs} = k + 1"
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2376 | unfolding natpermute_contain_maximal | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2377 | proof - | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2378 |   let ?A = "\<lambda>i. {replicate (k + 1) 0[i := n]}"
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2379 |   let ?K = "{0 ..k}"
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2380 | have fK: "finite ?K" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2381 | by simp | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2382 | have fAK: "\<forall>i\<in>?K. finite (?A i)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2383 | by auto | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2384 | have d: "\<forall>i\<in> ?K. \<forall>j\<in> ?K. i \<noteq> j \<longrightarrow> | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2385 |     {replicate (k + 1) 0[i := n]} \<inter> {replicate (k + 1) 0[j := n]} = {}"
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2386 | proof clarify | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2387 | fix i j | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2388 | assume i: "i \<in> ?K" and j: "j \<in> ?K" and ij: "i \<noteq> j" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2389 | have False if eq: "replicate (k+1) 0 [i:=n] = replicate (k+1) 0 [j:= n]" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2390 | proof - | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2391 | have "(replicate (k+1) 0 [i:=n] ! i) = n" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2392 | using i by (simp del: replicate.simps) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2393 | moreover | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2394 | have "(replicate (k+1) 0 [j:=n] ! i) = 0" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2395 | using i ij by (simp del: replicate.simps) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2396 | ultimately show ?thesis | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2397 | using eq n0 by (simp del: replicate.simps) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2398 | qed | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2399 |     then show "{replicate (k + 1) 0[i := n]} \<inter> {replicate (k + 1) 0[j := n]} = {}"
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2400 | by auto | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2401 | qed | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2402 | from card_UN_disjoint[OF fK fAK d] | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2403 |   show "card (\<Union>i\<in>{0..k}. {replicate (k + 1) 0[i := n]}) = k + 1"
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2404 | by simp | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2405 | qed | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2406 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2407 | lemma fps_power_Suc_nth: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2408 | fixes f :: "'a :: comm_ring_1 fps" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2409 | assumes k: "k > 0" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2410 | shows "(f ^ Suc m) $ k = | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2411 | of_nat (Suc m) * (f $ k * (f $ 0) ^ m) + | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2412 |            (\<Sum>v\<in>{v\<in>natpermute k (m+1). k \<notin> set v}. \<Prod>j = 0..m. f $ v ! j)"
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2413 | proof - | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2414 | define A B | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2415 |     where "A = {v\<in>natpermute k (m+1). k \<in> set v}" 
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2416 |       and  "B = {v\<in>natpermute k (m+1). k \<notin> set v}"
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2417 |   have [simp]: "finite A" "finite B" "A \<inter> B = {}" by (auto simp: A_def B_def natpermute_finite)
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2418 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2419 | from natpermute_max_card[of k m] k have card_A: "card A = m + 1" by (simp add: A_def) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2420 |   {
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2421 | fix v assume v: "v \<in> A" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2422 | from v have [simp]: "length v = Suc m" by (simp add: A_def natpermute_def) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2423 | from v have "\<exists>j. j \<le> m \<and> v ! j = k" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2424 | by (auto simp: set_conv_nth A_def natpermute_def less_Suc_eq_le) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2425 | then guess j by (elim exE conjE) note j = this | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2426 | |
| 63882 
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
 nipkow parents: 
63589diff
changeset | 2427 | from v have "k = sum_list v" by (simp add: A_def natpermute_def) | 
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2428 | also have "\<dots> = (\<Sum>i=0..m. v ! i)" | 
| 64267 | 2429 | by (simp add: sum_list_sum_nth atLeastLessThanSuc_atLeastAtMost del: sum_op_ivl_Suc) | 
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2430 |     also from j have "{0..m} = insert j ({0..m}-{j})" by auto
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2431 |     also from j have "(\<Sum>i\<in>\<dots>. v ! i) = k + (\<Sum>i\<in>{0..m}-{j}. v ! i)"
 | 
| 64267 | 2432 | by (subst sum.insert) simp_all | 
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2433 |     finally have "(\<Sum>i\<in>{0..m}-{j}. v ! i) = 0" by simp
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2434 |     hence zero: "v ! i = 0" if "i \<in> {0..m}-{j}" for i using that
 | 
| 64267 | 2435 | by (subst (asm) sum_eq_0_iff) auto | 
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2436 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2437 |     from j have "{0..m} = insert j ({0..m} - {j})" by auto
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2438 |     also from j have "(\<Prod>i\<in>\<dots>. f $ (v ! i)) = f $ k * (\<Prod>i\<in>{0..m} - {j}. f $ (v ! i))"
 | 
| 64272 | 2439 | by (subst prod.insert) auto | 
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2440 |     also have "(\<Prod>i\<in>{0..m} - {j}. f $ (v ! i)) = (\<Prod>i\<in>{0..m} - {j}. f $ 0)"
 | 
| 64272 | 2441 | by (intro prod.cong) (simp_all add: zero) | 
| 2442 | also from j have "\<dots> = (f $ 0) ^ m" by (subst prod_constant) simp_all | |
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2443 | finally have "(\<Prod>j = 0..m. f $ (v ! j)) = f $ k * (f $ 0) ^ m" . | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2444 | } note A = this | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2445 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2446 | have "(f ^ Suc m) $ k = (\<Sum>v\<in>natpermute k (m + 1). \<Prod>j = 0..m. f $ v ! j)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2447 | by (rule fps_power_nth_Suc) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2448 | also have "natpermute k (m+1) = A \<union> B" unfolding A_def B_def by blast | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2449 | also have "(\<Sum>v\<in>\<dots>. \<Prod>j = 0..m. f $ (v ! j)) = | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2450 | (\<Sum>v\<in>A. \<Prod>j = 0..m. f $ (v ! j)) + (\<Sum>v\<in>B. \<Prod>j = 0..m. f $ (v ! j))" | 
| 64267 | 2451 | by (intro sum.union_disjoint) simp_all | 
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2452 | also have "(\<Sum>v\<in>A. \<Prod>j = 0..m. f $ (v ! j)) = of_nat (Suc m) * (f $ k * (f $ 0) ^ m)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2453 | by (simp add: A card_A) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2454 | finally show ?thesis by (simp add: B_def) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2455 | qed | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2456 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2457 | lemma fps_power_Suc_eqD: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2458 |   fixes f g :: "'a :: {idom,semiring_char_0} fps"
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2459 | assumes "f ^ Suc m = g ^ Suc m" "f $ 0 = g $ 0" "f $ 0 \<noteq> 0" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2460 | shows "f = g" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2461 | proof (rule fps_ext) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2462 | fix k :: nat | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2463 | show "f $ k = g $ k" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2464 | proof (induction k rule: less_induct) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2465 | case (less k) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2466 | show ?case | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2467 | proof (cases "k = 0") | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2468 | case False | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2469 | let ?h = "\<lambda>f. (\<Sum>v | v \<in> natpermute k (m + 1) \<and> k \<notin> set v. \<Prod>j = 0..m. f $ v ! j)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2470 | from False fps_power_Suc_nth[of k f m] fps_power_Suc_nth[of k g m] | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2471 | have "f $ k * (of_nat (Suc m) * (f $ 0) ^ m) + ?h f = | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2472 | g $ k * (of_nat (Suc m) * (f $ 0) ^ m) + ?h g" using assms | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2473 | by (simp add: mult_ac del: power_Suc of_nat_Suc) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2474 |       also have "v ! i < k" if "v \<in> {v\<in>natpermute k (m+1). k \<notin> set v}" "i \<le> m" for v i
 | 
| 63882 
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
 nipkow parents: 
63589diff
changeset | 2475 | using that elem_le_sum_list_nat[of i v] unfolding natpermute_def | 
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2476 | by (auto simp: set_conv_nth dest!: spec[of _ i]) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2477 | hence "?h f = ?h g" | 
| 64272 | 2478 | by (intro sum.cong refl prod.cong less lessI) (auto simp: natpermute_def) | 
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2479 | finally have "f $ k * (of_nat (Suc m) * (f $ 0) ^ m) = g $ k * (of_nat (Suc m) * (f $ 0) ^ m)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2480 | by simp | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2481 | with assms show "f $ k = g $ k" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2482 | by (subst (asm) mult_right_cancel) (auto simp del: of_nat_Suc) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2483 | qed (simp_all add: assms) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2484 | qed | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2485 | qed | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2486 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2487 | lemma fps_power_Suc_eqD': | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2488 |   fixes f g :: "'a :: {idom,semiring_char_0} fps"
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2489 | assumes "f ^ Suc m = g ^ Suc m" "f $ subdegree f = g $ subdegree g" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2490 | shows "f = g" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2491 | proof (cases "f = 0") | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2492 | case False | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2493 | have "Suc m * subdegree f = subdegree (f ^ Suc m)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2494 | by (rule subdegree_power [symmetric]) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2495 | also have "f ^ Suc m = g ^ Suc m" by fact | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2496 | also have "subdegree \<dots> = Suc m * subdegree g" by (rule subdegree_power) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2497 | finally have [simp]: "subdegree f = subdegree g" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2498 | by (subst (asm) Suc_mult_cancel1) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2499 | have "fps_shift (subdegree f) f * X ^ subdegree f = f" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2500 | by (rule subdegree_decompose [symmetric]) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2501 | also have "\<dots> ^ Suc m = g ^ Suc m" by fact | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2502 | also have "g = fps_shift (subdegree g) g * X ^ subdegree g" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2503 | by (rule subdegree_decompose) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2504 | also have "subdegree f = subdegree g" by fact | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2505 | finally have "fps_shift (subdegree g) f ^ Suc m = fps_shift (subdegree g) g ^ Suc m" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2506 | by (simp add: algebra_simps power_mult_distrib del: power_Suc) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2507 | hence "fps_shift (subdegree g) f = fps_shift (subdegree g) g" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2508 | by (rule fps_power_Suc_eqD) (insert assms False, auto) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2509 | with subdegree_decompose[of f] subdegree_decompose[of g] show ?thesis by simp | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2510 | qed (insert assms, simp_all) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2511 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2512 | lemma fps_power_eqD': | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2513 |   fixes f g :: "'a :: {idom,semiring_char_0} fps"
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2514 | assumes "f ^ m = g ^ m" "f $ subdegree f = g $ subdegree g" "m > 0" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2515 | shows "f = g" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2516 | using fps_power_Suc_eqD'[of f "m-1" g] assms by simp | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2517 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2518 | lemma fps_power_eqD: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2519 |   fixes f g :: "'a :: {idom,semiring_char_0} fps"
 | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2520 | assumes "f ^ m = g ^ m" "f $ 0 = g $ 0" "f $ 0 \<noteq> 0" "m > 0" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2521 | shows "f = g" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2522 | by (rule fps_power_eqD'[of f m g]) (insert assms, simp_all) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 2523 | |
| 30488 | 2524 | lemma fps_compose_inj_right: | 
| 54681 | 2525 | assumes a0: "a$0 = (0::'a::idom)" | 
| 52902 | 2526 | and a1: "a$1 \<noteq> 0" | 
| 54681 | 2527 | shows "(b oo a = c oo a) \<longleftrightarrow> b = c" | 
| 2528 | (is "?lhs \<longleftrightarrow>?rhs") | |
| 53196 | 2529 | proof | 
| 60501 | 2530 | show ?lhs if ?rhs using that by simp | 
| 2531 | show ?rhs if ?lhs | |
| 2532 | proof - | |
| 2533 | have "b$n = c$n" for n | |
| 53196 | 2534 | proof (induct n rule: nat_less_induct) | 
| 2535 | fix n | |
| 2536 | assume H: "\<forall>m<n. b$m = c$m" | |
| 60501 | 2537 | show "b$n = c$n" | 
| 2538 | proof (cases n) | |
| 2539 | case 0 | |
| 2540 | from \<open>?lhs\<close> have "(b oo a)$n = (c oo a)$n" | |
| 2541 | by simp | |
| 2542 | then show ?thesis | |
| 2543 | using 0 by (simp add: fps_compose_nth) | |
| 2544 | next | |
| 2545 | case (Suc n1) | |
| 53196 | 2546 |         have f: "finite {0 .. n1}" "finite {n}" by simp_all
 | 
| 60501 | 2547 |         have eq: "{0 .. n1} \<union> {n} = {0 .. n}" using Suc by auto
 | 
| 2548 |         have d: "{0 .. n1} \<inter> {n} = {}" using Suc by auto
 | |
| 53196 | 2549 | have seq: "(\<Sum>i = 0..n1. b $ i * a ^ i $ n) = (\<Sum>i = 0..n1. c $ i * a ^ i $ n)" | 
| 64267 | 2550 | apply (rule sum.cong) | 
| 60501 | 2551 | using H Suc | 
| 53196 | 2552 | apply auto | 
| 2553 | done | |
| 2554 | have th0: "(b oo a) $n = (\<Sum>i = 0..n1. c $ i * a ^ i $ n) + b$n * (a$1)^n" | |
| 64267 | 2555 | unfolding fps_compose_nth sum.union_disjoint[OF f d, unfolded eq] seq | 
| 53196 | 2556 | using startsby_zero_power_nth_same[OF a0] | 
| 2557 | by simp | |
| 2558 | have th1: "(c oo a) $n = (\<Sum>i = 0..n1. c $ i * a ^ i $ n) + c$n * (a$1)^n" | |
| 64267 | 2559 | unfolding fps_compose_nth sum.union_disjoint[OF f d, unfolded eq] | 
| 53196 | 2560 | using startsby_zero_power_nth_same[OF a0] | 
| 2561 | by simp | |
| 60501 | 2562 | from \<open>?lhs\<close>[unfolded fps_eq_iff, rule_format, of n] th0 th1 a1 | 
| 2563 | show ?thesis by auto | |
| 2564 | qed | |
| 2565 | qed | |
| 2566 | then show ?rhs by (simp add: fps_eq_iff) | |
| 2567 | qed | |
| 29687 | 2568 | qed | 
| 2569 | ||
| 2570 | ||
| 60500 | 2571 | subsection \<open>Radicals\<close> | 
| 29687 | 2572 | |
| 64272 | 2573 | declare prod.cong [fundef_cong] | 
| 52903 | 2574 | |
| 54681 | 2575 | function radical :: "(nat \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> nat \<Rightarrow> 'a::field fps \<Rightarrow> nat \<Rightarrow> 'a" | 
| 52902 | 2576 | where | 
| 29687 | 2577 | "radical r 0 a 0 = 1" | 
| 2578 | | "radical r 0 a (Suc n) = 0" | |
| 2579 | | "radical r (Suc k) a 0 = r (Suc k) (a$0)" | |
| 48757 | 2580 | | "radical r (Suc k) a (Suc n) = | 
| 64272 | 2581 |     (a$ Suc n - sum (\<lambda>xs. prod (\<lambda>j. radical r (Suc k) a (xs ! j)) {0..k})
 | 
| 48757 | 2582 |       {xs. xs \<in> natpermute (Suc n) (Suc k) \<and> Suc n \<notin> set xs}) /
 | 
| 2583 | (of_nat (Suc k) * (radical r (Suc k) a 0)^k)" | |
| 52902 | 2584 | by pat_completeness auto | 
| 29687 | 2585 | |
| 2586 | termination radical | |
| 2587 | proof | |
| 2588 | let ?R = "measure (\<lambda>(r, k, a, n). n)" | |
| 2589 |   {
 | |
| 52902 | 2590 | show "wf ?R" by auto | 
| 2591 | next | |
| 2592 | fix r k a n xs i | |
| 29687 | 2593 |     assume xs: "xs \<in> {xs \<in> natpermute (Suc n) (Suc k). Suc n \<notin> set xs}" and i: "i \<in> {0..k}"
 | 
| 60558 | 2594 | have False if c: "Suc n \<le> xs ! i" | 
| 2595 | proof - | |
| 52902 | 2596 | from xs i have "xs !i \<noteq> Suc n" | 
| 2597 | by (auto simp add: in_set_conv_nth natpermute_def) | |
| 29687 | 2598 | with c have c': "Suc n < xs!i" by arith | 
| 52902 | 2599 |       have fths: "finite {0 ..< i}" "finite {i}" "finite {i+1..<Suc k}"
 | 
| 2600 | by simp_all | |
| 2601 |       have d: "{0 ..< i} \<inter> ({i} \<union> {i+1 ..< Suc k}) = {}" "{i} \<inter> {i+1..< Suc k} = {}"
 | |
| 2602 | by auto | |
| 2603 |       have eqs: "{0..<Suc k} = {0 ..< i} \<union> ({i} \<union> {i+1 ..< Suc k})"
 | |
| 2604 | using i by auto | |
| 63882 
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
 nipkow parents: 
63589diff
changeset | 2605 | from xs have "Suc n = sum_list xs" | 
| 52902 | 2606 | by (simp add: natpermute_def) | 
| 64267 | 2607 |       also have "\<dots> = sum (nth xs) {0..<Suc k}" using xs
 | 
| 2608 | by (simp add: natpermute_def sum_list_sum_nth) | |
| 2609 |       also have "\<dots> = xs!i + sum (nth xs) {0..<i} + sum (nth xs) {i+1..<Suc k}"
 | |
| 2610 | unfolding eqs sum.union_disjoint[OF fths(1) finite_UnI[OF fths(2,3)] d(1)] | |
| 2611 | unfolding sum.union_disjoint[OF fths(2) fths(3) d(2)] | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2612 | by simp | 
| 60558 | 2613 | finally show ?thesis using c' by simp | 
| 2614 | qed | |
| 52902 | 2615 | then show "((r, Suc k, a, xs!i), r, Suc k, a, Suc n) \<in> ?R" | 
| 2616 | apply auto | |
| 2617 | apply (metis not_less) | |
| 2618 | done | |
| 2619 | next | |
| 2620 | fix r k a n | |
| 2621 | show "((r, Suc k, a, 0), r, Suc k, a, Suc n) \<in> ?R" by simp | |
| 2622 | } | |
| 29687 | 2623 | qed | 
| 2624 | ||
| 2625 | definition "fps_radical r n a = Abs_fps (radical r n a)" | |
| 2626 | ||
| 2627 | lemma fps_radical0[simp]: "fps_radical r 0 a = 1" | |
| 52902 | 2628 | apply (auto simp add: fps_eq_iff fps_radical_def) | 
| 2629 | apply (case_tac n) | |
| 2630 | apply auto | |
| 2631 | done | |
| 29687 | 2632 | |
| 60501 | 2633 | lemma fps_radical_nth_0[simp]: "fps_radical r n a $ 0 = (if n = 0 then 1 else r n (a$0))" | 
| 52902 | 2634 | by (cases n) (simp_all add: fps_radical_def) | 
| 29687 | 2635 | |
| 30488 | 2636 | lemma fps_radical_power_nth[simp]: | 
| 29687 | 2637 | assumes r: "(r k (a$0)) ^ k = a$0" | 
| 2638 | shows "fps_radical r k a ^ k $ 0 = (if k = 0 then 1 else a$0)" | |
| 53196 | 2639 | proof (cases k) | 
| 2640 | case 0 | |
| 2641 | then show ?thesis by simp | |
| 2642 | next | |
| 2643 | case (Suc h) | |
| 2644 |   have eq1: "fps_radical r k a ^ k $ 0 = (\<Prod>j\<in>{0..h}. fps_radical r k a $ (replicate k 0) ! j)"
 | |
| 2645 | unfolding fps_power_nth Suc by simp | |
| 2646 |   also have "\<dots> = (\<Prod>j\<in>{0..h}. r k (a$0))"
 | |
| 64272 | 2647 | apply (rule prod.cong) | 
| 53196 | 2648 | apply simp | 
| 2649 | using Suc | |
| 54681 | 2650 | apply (subgoal_tac "replicate k 0 ! x = 0") | 
| 53196 | 2651 | apply (auto intro: nth_replicate simp del: replicate.simps) | 
| 2652 | done | |
| 60501 | 2653 | also have "\<dots> = a$0" | 
| 64272 | 2654 | using r Suc by (simp add: prod_constant) | 
| 60501 | 2655 | finally show ?thesis | 
| 2656 | using Suc by simp | |
| 30488 | 2657 | qed | 
| 29687 | 2658 | |
| 30488 | 2659 | lemma power_radical: | 
| 31273 | 2660 | fixes a:: "'a::field_char_0 fps" | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2661 | assumes a0: "a$0 \<noteq> 0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2662 | shows "(r (Suc k) (a$0)) ^ Suc k = a$0 \<longleftrightarrow> (fps_radical r (Suc k) a) ^ (Suc k) = a" | 
| 60558 | 2663 | (is "?lhs \<longleftrightarrow> ?rhs") | 
| 2664 | proof | |
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2665 | let ?r = "fps_radical r (Suc k) a" | 
| 60558 | 2666 | show ?rhs if r0: ?lhs | 
| 2667 | proof - | |
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2668 | from a0 r0 have r00: "r (Suc k) (a$0) \<noteq> 0" by auto | 
| 60501 | 2669 | have "?r ^ Suc k $ z = a$z" for z | 
| 2670 | proof (induct z rule: nat_less_induct) | |
| 2671 | fix n | |
| 2672 | assume H: "\<forall>m<n. ?r ^ Suc k $ m = a$m" | |
| 2673 | show "?r ^ Suc k $ n = a $n" | |
| 2674 | proof (cases n) | |
| 2675 | case 0 | |
| 2676 | then show ?thesis | |
| 2677 | using fps_radical_power_nth[of r "Suc k" a, OF r0] by simp | |
| 2678 | next | |
| 2679 | case (Suc n1) | |
| 2680 | then have "n \<noteq> 0" by simp | |
| 2681 | let ?Pnk = "natpermute n (k + 1)" | |
| 2682 |         let ?Pnkn = "{xs \<in> ?Pnk. n \<in> set xs}"
 | |
| 2683 |         let ?Pnknn = "{xs \<in> ?Pnk. n \<notin> set xs}"
 | |
| 2684 | have eq: "?Pnkn \<union> ?Pnknn = ?Pnk" by blast | |
| 2685 |         have d: "?Pnkn \<inter> ?Pnknn = {}" by blast
 | |
| 2686 | have f: "finite ?Pnkn" "finite ?Pnknn" | |
| 2687 | using finite_Un[of ?Pnkn ?Pnknn, unfolded eq] | |
| 2688 | by (metis natpermute_finite)+ | |
| 2689 |         let ?f = "\<lambda>v. \<Prod>j\<in>{0..k}. ?r $ v ! j"
 | |
| 64267 | 2690 | have "sum ?f ?Pnkn = sum (\<lambda>v. ?r $ n * r (Suc k) (a $ 0) ^ k) ?Pnkn" | 
| 2691 | proof (rule sum.cong) | |
| 60501 | 2692 |           fix v assume v: "v \<in> {xs \<in> natpermute n (k + 1). n \<in> set xs}"
 | 
| 2693 |           let ?ths = "(\<Prod>j\<in>{0..k}. fps_radical r (Suc k) a $ v ! j) =
 | |
| 2694 | fps_radical r (Suc k) a $ n * r (Suc k) (a $ 0) ^ k" | |
| 2695 |           from v obtain i where i: "i \<in> {0..k}" "v = replicate (k+1) 0 [i:= n]"
 | |
| 2696 | unfolding natpermute_contain_maximal by auto | |
| 2697 |           have "(\<Prod>j\<in>{0..k}. fps_radical r (Suc k) a $ v ! j) =
 | |
| 2698 |               (\<Prod>j\<in>{0..k}. if j = i then fps_radical r (Suc k) a $ n else r (Suc k) (a$0))"
 | |
| 64272 | 2699 | apply (rule prod.cong, simp) | 
| 60501 | 2700 | using i r0 | 
| 2701 | apply (simp del: replicate.simps) | |
| 2702 | done | |
| 2703 | also have "\<dots> = (fps_radical r (Suc k) a $ n) * r (Suc k) (a$0) ^ k" | |
| 64272 | 2704 | using i r0 by (simp add: prod_gen_delta) | 
| 60501 | 2705 | finally show ?ths . | 
| 2706 | qed rule | |
| 64267 | 2707 | then have "sum ?f ?Pnkn = of_nat (k+1) * ?r $ n * r (Suc k) (a $ 0) ^ k" | 
| 60501 | 2708 | by (simp add: natpermute_max_card[OF \<open>n \<noteq> 0\<close>, simplified]) | 
| 64267 | 2709 | also have "\<dots> = a$n - sum ?f ?Pnknn" | 
| 60501 | 2710 | unfolding Suc using r00 a0 by (simp add: field_simps fps_radical_def del: of_nat_Suc) | 
| 64267 | 2711 | finally have fn: "sum ?f ?Pnkn = a$n - sum ?f ?Pnknn" . | 
| 2712 | have "(?r ^ Suc k)$n = sum ?f ?Pnkn + sum ?f ?Pnknn" | |
| 2713 | unfolding fps_power_nth_Suc sum.union_disjoint[OF f d, unfolded eq] .. | |
| 60501 | 2714 | also have "\<dots> = a$n" unfolding fn by simp | 
| 2715 | finally show ?thesis . | |
| 52903 | 2716 | qed | 
| 60501 | 2717 | qed | 
| 60558 | 2718 | then show ?thesis using r0 by (simp add: fps_eq_iff) | 
| 2719 | qed | |
| 2720 | show ?lhs if ?rhs | |
| 2721 | proof - | |
| 2722 | from that have "((fps_radical r (Suc k) a) ^ (Suc k))$0 = a$0" | |
| 2723 | by simp | |
| 2724 | then show ?thesis | |
| 52903 | 2725 | unfolding fps_power_nth_Suc | 
| 64272 | 2726 | by (simp add: prod_constant del: replicate.simps) | 
| 60558 | 2727 | qed | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2728 | qed | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2729 | |
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2730 | (* | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2731 | lemma power_radical: | 
| 31273 | 2732 | fixes a:: "'a::field_char_0 fps" | 
| 29687 | 2733 | assumes r0: "(r (Suc k) (a$0)) ^ Suc k = a$0" and a0: "a$0 \<noteq> 0" | 
| 30488 | 2734 | shows "(fps_radical r (Suc k) a) ^ (Suc k) = a" | 
| 29687 | 2735 | proof- | 
| 2736 | let ?r = "fps_radical r (Suc k) a" | |
| 2737 | from a0 r0 have r00: "r (Suc k) (a$0) \<noteq> 0" by auto | |
| 2738 |   {fix z have "?r ^ Suc k $ z = a$z"
 | |
| 2739 | proof(induct z rule: nat_less_induct) | |
| 2740 | fix n assume H: "\<forall>m<n. ?r ^ Suc k $ m = a$m" | |
| 54452 | 2741 |       {assume "n = 0" then have "?r ^ Suc k $ n = a $n"
 | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2742 | using fps_radical_power_nth[of r "Suc k" a, OF r0] by simp} | 
| 29687 | 2743 | moreover | 
| 2744 |       {fix n1 assume n1: "n = Suc n1"
 | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2745 |         have fK: "finite {0..k}" by simp
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2746 | have nz: "n \<noteq> 0" using n1 by arith | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2747 | let ?Pnk = "natpermute n (k + 1)" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2748 |         let ?Pnkn = "{xs \<in> ?Pnk. n \<in> set xs}"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2749 |         let ?Pnknn = "{xs \<in> ?Pnk. n \<notin> set xs}"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2750 | have eq: "?Pnkn \<union> ?Pnknn = ?Pnk" by blast | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2751 |         have d: "?Pnkn \<inter> ?Pnknn = {}" by blast
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2752 | have f: "finite ?Pnkn" "finite ?Pnknn" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2753 | using finite_Un[of ?Pnkn ?Pnknn, unfolded eq] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2754 | by (metis natpermute_finite)+ | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2755 |         let ?f = "\<lambda>v. \<Prod>j\<in>{0..k}. ?r $ v ! j"
 | 
| 64267 | 2756 | have "sum ?f ?Pnkn = sum (\<lambda>v. ?r $ n * r (Suc k) (a $ 0) ^ k) ?Pnkn" | 
| 2757 | proof(rule sum.cong2) | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2758 |           fix v assume v: "v \<in> {xs \<in> natpermute n (k + 1). n \<in> set xs}"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2759 |           let ?ths = "(\<Prod>j\<in>{0..k}. fps_radical r (Suc k) a $ v ! j) = fps_radical r (Suc k) a $ n * r (Suc k) (a $ 0) ^ k"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2760 |           from v obtain i where i: "i \<in> {0..k}" "v = replicate (k+1) 0 [i:= n]"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2761 | unfolding natpermute_contain_maximal by auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2762 |           have "(\<Prod>j\<in>{0..k}. fps_radical r (Suc k) a $ v ! j) = (\<Prod>j\<in>{0..k}. if j = i then fps_radical r (Suc k) a $ n else r (Suc k) (a$0))"
 | 
| 64272 | 2763 | apply (rule prod.cong, simp) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2764 | using i r0 by (simp del: replicate.simps) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2765 | also have "\<dots> = (fps_radical r (Suc k) a $ n) * r (Suc k) (a$0) ^ k" | 
| 64272 | 2766 | unfolding prod_gen_delta[OF fK] using i r0 by simp | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2767 | finally show ?ths . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2768 | qed | 
| 64267 | 2769 | then have "sum ?f ?Pnkn = of_nat (k+1) * ?r $ n * r (Suc k) (a $ 0) ^ k" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2770 | by (simp add: natpermute_max_card[OF nz, simplified]) | 
| 64267 | 2771 | also have "\<dots> = a$n - sum ?f ?Pnknn" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2772 | unfolding n1 using r00 a0 by (simp add: field_simps fps_radical_def del: of_nat_Suc ) | 
| 64267 | 2773 | finally have fn: "sum ?f ?Pnkn = a$n - sum ?f ?Pnknn" . | 
| 2774 | have "(?r ^ Suc k)$n = sum ?f ?Pnkn + sum ?f ?Pnknn" | |
| 2775 | unfolding fps_power_nth_Suc sum.union_disjoint[OF f d, unfolded eq] .. | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2776 | also have "\<dots> = a$n" unfolding fn by simp | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2777 | finally have "?r ^ Suc k $ n = a $n" .} | 
| 29687 | 2778 | ultimately show "?r ^ Suc k $ n = a $n" by (cases n, auto) | 
| 2779 | qed } | |
| 2780 | then show ?thesis by (simp add: fps_eq_iff) | |
| 2781 | qed | |
| 2782 | ||
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2783 | *) | 
| 52903 | 2784 | lemma eq_divide_imp': | 
| 60501 | 2785 | fixes c :: "'a::field" | 
| 2786 | shows "c \<noteq> 0 \<Longrightarrow> a * c = b \<Longrightarrow> a = b / c" | |
| 56480 
093ea91498e6
field_simps: better support for negation and division, and power
 hoelzl parents: 
56479diff
changeset | 2787 | by (simp add: field_simps) | 
| 29687 | 2788 | |
| 30488 | 2789 | lemma radical_unique: | 
| 2790 | assumes r0: "(r (Suc k) (b$0)) ^ Suc k = b$0" | |
| 52903 | 2791 | and a0: "r (Suc k) (b$0 ::'a::field_char_0) = a$0" | 
| 2792 | and b0: "b$0 \<noteq> 0" | |
| 29687 | 2793 | shows "a^(Suc k) = b \<longleftrightarrow> a = fps_radical r (Suc k) b" | 
| 60501 | 2794 | (is "?lhs \<longleftrightarrow> ?rhs" is "_ \<longleftrightarrow> a = ?r") | 
| 2795 | proof | |
| 2796 | show ?lhs if ?rhs | |
| 2797 | using that using power_radical[OF b0, of r k, unfolded r0] by simp | |
| 2798 | show ?rhs if ?lhs | |
| 2799 | proof - | |
| 2800 | have r00: "r (Suc k) (b$0) \<noteq> 0" using b0 r0 by auto | |
| 29687 | 2801 |     have ceq: "card {0..k} = Suc k" by simp
 | 
| 2802 | from a0 have a0r0: "a$0 = ?r$0" by simp | |
| 60501 | 2803 | have "a $ n = ?r $ n" for n | 
| 2804 | proof (induct n rule: nat_less_induct) | |
| 52903 | 2805 | fix n | 
| 60501 | 2806 | assume h: "\<forall>m<n. a$m = ?r $m" | 
| 2807 | show "a$n = ?r $ n" | |
| 2808 | proof (cases n) | |
| 2809 | case 0 | |
| 2810 | then show ?thesis using a0 by simp | |
| 2811 | next | |
| 2812 | case (Suc n1) | |
| 2813 |         have fK: "finite {0..k}" by simp
 | |
| 2814 | have nz: "n \<noteq> 0" using Suc by simp | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2815 | let ?Pnk = "natpermute n (Suc k)" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2816 |         let ?Pnkn = "{xs \<in> ?Pnk. n \<in> set xs}"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2817 |         let ?Pnknn = "{xs \<in> ?Pnk. n \<notin> set xs}"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2818 | have eq: "?Pnkn \<union> ?Pnknn = ?Pnk" by blast | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2819 |         have d: "?Pnkn \<inter> ?Pnknn = {}" by blast
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2820 | have f: "finite ?Pnkn" "finite ?Pnknn" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2821 | using finite_Un[of ?Pnkn ?Pnknn, unfolded eq] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2822 | by (metis natpermute_finite)+ | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2823 |         let ?f = "\<lambda>v. \<Prod>j\<in>{0..k}. ?r $ v ! j"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2824 |         let ?g = "\<lambda>v. \<Prod>j\<in>{0..k}. a $ v ! j"
 | 
| 64267 | 2825 | have "sum ?g ?Pnkn = sum (\<lambda>v. a $ n * (?r$0)^k) ?Pnkn" | 
| 2826 | proof (rule sum.cong) | |
| 52903 | 2827 | fix v | 
| 2828 |           assume v: "v \<in> {xs \<in> natpermute n (Suc k). n \<in> set xs}"
 | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2829 |           let ?ths = "(\<Prod>j\<in>{0..k}. a $ v ! j) = a $ n * (?r$0)^k"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2830 |           from v obtain i where i: "i \<in> {0..k}" "v = replicate (k+1) 0 [i:= n]"
 | 
| 52903 | 2831 | unfolding Suc_eq_plus1 natpermute_contain_maximal | 
| 2832 | by (auto simp del: replicate.simps) | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2833 |           have "(\<Prod>j\<in>{0..k}. a $ v ! j) = (\<Prod>j\<in>{0..k}. if j = i then a $ n else r (Suc k) (b$0))"
 | 
| 64272 | 2834 | apply (rule prod.cong, simp) | 
| 54452 | 2835 | using i a0 | 
| 2836 | apply (simp del: replicate.simps) | |
| 52903 | 2837 | done | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2838 | also have "\<dots> = a $ n * (?r $ 0)^k" | 
| 64272 | 2839 | using i by (simp add: prod_gen_delta) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2840 | finally show ?ths . | 
| 57418 | 2841 | qed rule | 
| 64267 | 2842 | then have th0: "sum ?g ?Pnkn = of_nat (k+1) * a $ n * (?r $ 0)^k" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2843 | by (simp add: natpermute_max_card[OF nz, simplified]) | 
| 64267 | 2844 | have th1: "sum ?g ?Pnknn = sum ?f ?Pnknn" | 
| 64272 | 2845 | proof (rule sum.cong, rule refl, rule prod.cong, simp) | 
| 52903 | 2846 | fix xs i | 
| 2847 |           assume xs: "xs \<in> ?Pnknn" and i: "i \<in> {0..k}"
 | |
| 60501 | 2848 | have False if c: "n \<le> xs ! i" | 
| 2849 | proof - | |
| 2850 | from xs i have "xs ! i \<noteq> n" | |
| 52903 | 2851 | by (auto simp add: in_set_conv_nth natpermute_def) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2852 | with c have c': "n < xs!i" by arith | 
| 52903 | 2853 |             have fths: "finite {0 ..< i}" "finite {i}" "finite {i+1..<Suc k}"
 | 
| 2854 | by simp_all | |
| 2855 |             have d: "{0 ..< i} \<inter> ({i} \<union> {i+1 ..< Suc k}) = {}" "{i} \<inter> {i+1..< Suc k} = {}"
 | |
| 2856 | by auto | |
| 2857 |             have eqs: "{0..<Suc k} = {0 ..< i} \<union> ({i} \<union> {i+1 ..< Suc k})"
 | |
| 2858 | using i by auto | |
| 63882 
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
 nipkow parents: 
63589diff
changeset | 2859 | from xs have "n = sum_list xs" | 
| 52903 | 2860 | by (simp add: natpermute_def) | 
| 64267 | 2861 |             also have "\<dots> = sum (nth xs) {0..<Suc k}"
 | 
| 2862 | using xs by (simp add: natpermute_def sum_list_sum_nth) | |
| 2863 |             also have "\<dots> = xs!i + sum (nth xs) {0..<i} + sum (nth xs) {i+1..<Suc k}"
 | |
| 2864 | unfolding eqs sum.union_disjoint[OF fths(1) finite_UnI[OF fths(2,3)] d(1)] | |
| 2865 | unfolding sum.union_disjoint[OF fths(2) fths(3) d(2)] | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2866 | by simp | 
| 60501 | 2867 | finally show ?thesis using c' by simp | 
| 2868 | qed | |
| 52902 | 2869 | then have thn: "xs!i < n" by presburger | 
| 52903 | 2870 | from h[rule_format, OF thn] show "a$(xs !i) = ?r$(xs!i)" . | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2871 | qed | 
| 54681 | 2872 | have th00: "\<And>x::'a. of_nat (Suc k) * (x * inverse (of_nat (Suc k))) = x" | 
| 36350 | 2873 | by (simp add: field_simps del: of_nat_Suc) | 
| 60501 | 2874 | from \<open>?lhs\<close> have "b$n = a^Suc k $ n" | 
| 52903 | 2875 | by (simp add: fps_eq_iff) | 
| 64267 | 2876 | also have "a ^ Suc k$n = sum ?g ?Pnkn + sum ?g ?Pnknn" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2877 | unfolding fps_power_nth_Suc | 
| 64267 | 2878 | using sum.union_disjoint[OF f d, unfolded Suc_eq_plus1[symmetric], | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2879 | unfolded eq, of ?g] by simp | 
| 64267 | 2880 | also have "\<dots> = of_nat (k+1) * a $ n * (?r $ 0)^k + sum ?f ?Pnknn" | 
| 52903 | 2881 | unfolding th0 th1 .. | 
| 64267 | 2882 | finally have "of_nat (k+1) * a $ n * (?r $ 0)^k = b$n - sum ?f ?Pnknn" | 
| 52903 | 2883 | by simp | 
| 64267 | 2884 | then have "a$n = (b$n - sum ?f ?Pnknn) / (of_nat (k+1) * (?r $ 0)^k)" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2885 | apply - | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2886 | apply (rule eq_divide_imp') | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2887 | using r00 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2888 | apply (simp del: of_nat_Suc) | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 2889 | apply (simp add: ac_simps) | 
| 52903 | 2890 | done | 
| 60501 | 2891 | then show ?thesis | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2892 | apply (simp del: of_nat_Suc) | 
| 60501 | 2893 | unfolding fps_radical_def Suc | 
| 2894 | apply (simp add: field_simps Suc th00 del: of_nat_Suc) | |
| 52903 | 2895 | done | 
| 2896 | qed | |
| 60501 | 2897 | qed | 
| 2898 | then show ?rhs by (simp add: fps_eq_iff) | |
| 2899 | qed | |
| 29687 | 2900 | qed | 
| 2901 | ||
| 2902 | ||
| 30488 | 2903 | lemma radical_power: | 
| 2904 | assumes r0: "r (Suc k) ((a$0) ^ Suc k) = a$0" | |
| 54681 | 2905 | and a0: "(a$0 :: 'a::field_char_0) \<noteq> 0" | 
| 29687 | 2906 | shows "(fps_radical r (Suc k) (a ^ Suc k)) = a" | 
| 52903 | 2907 | proof - | 
| 29687 | 2908 | let ?ak = "a^ Suc k" | 
| 52903 | 2909 | have ak0: "?ak $ 0 = (a$0) ^ Suc k" | 
| 2910 | by (simp add: fps_nth_power_0 del: power_Suc) | |
| 2911 | from r0 have th0: "r (Suc k) (a ^ Suc k $ 0) ^ Suc k = a ^ Suc k $ 0" | |
| 2912 | using ak0 by auto | |
| 2913 | from r0 ak0 have th1: "r (Suc k) (a ^ Suc k $ 0) = a $ 0" | |
| 2914 | by auto | |
| 2915 | from ak0 a0 have ak00: "?ak $ 0 \<noteq>0 " | |
| 2916 | by auto | |
| 2917 | from radical_unique[of r k ?ak a, OF th0 th1 ak00] show ?thesis | |
| 2918 | by metis | |
| 29687 | 2919 | qed | 
| 2920 | ||
| 30488 | 2921 | lemma fps_deriv_radical: | 
| 54681 | 2922 | fixes a :: "'a::field_char_0 fps" | 
| 52903 | 2923 | assumes r0: "(r (Suc k) (a$0)) ^ Suc k = a$0" | 
| 2924 | and a0: "a$0 \<noteq> 0" | |
| 53196 | 2925 | shows "fps_deriv (fps_radical r (Suc k) a) = | 
| 2926 | fps_deriv a / (fps_const (of_nat (Suc k)) * (fps_radical r (Suc k) a) ^ k)" | |
| 52903 | 2927 | proof - | 
| 2928 | let ?r = "fps_radical r (Suc k) a" | |
| 29687 | 2929 | let ?w = "(fps_const (of_nat (Suc k)) * ?r ^ k)" | 
| 52903 | 2930 | from a0 r0 have r0': "r (Suc k) (a$0) \<noteq> 0" | 
| 2931 | by auto | |
| 2932 | from r0' have w0: "?w $ 0 \<noteq> 0" | |
| 2933 | by (simp del: of_nat_Suc) | |
| 29687 | 2934 | note th0 = inverse_mult_eq_1[OF w0] | 
| 2935 | let ?iw = "inverse ?w" | |
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2936 | from iffD1[OF power_radical[of a r], OF a0 r0] | 
| 52903 | 2937 | have "fps_deriv (?r ^ Suc k) = fps_deriv a" | 
| 2938 | by simp | |
| 54452 | 2939 | then have "fps_deriv ?r * ?w = fps_deriv a" | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 2940 | by (simp add: fps_deriv_power ac_simps del: power_Suc) | 
| 54452 | 2941 | then have "?iw * fps_deriv ?r * ?w = ?iw * fps_deriv a" | 
| 52903 | 2942 | by simp | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 2943 | with a0 r0 have "fps_deriv ?r * (?iw * ?w) = fps_deriv a / ?w" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 2944 | by (subst fps_divide_unit) (auto simp del: of_nat_Suc) | 
| 30488 | 2945 | then show ?thesis unfolding th0 by simp | 
| 29687 | 2946 | qed | 
| 2947 | ||
| 30488 | 2948 | lemma radical_mult_distrib: | 
| 54681 | 2949 | fixes a :: "'a::field_char_0 fps" | 
| 48757 | 2950 | assumes k: "k > 0" | 
| 2951 | and ra0: "r k (a $ 0) ^ k = a $ 0" | |
| 2952 | and rb0: "r k (b $ 0) ^ k = b $ 0" | |
| 60558 | 2953 | and a0: "a $ 0 \<noteq> 0" | 
| 2954 | and b0: "b $ 0 \<noteq> 0" | |
| 48757 | 2955 | shows "r k ((a * b) $ 0) = r k (a $ 0) * r k (b $ 0) \<longleftrightarrow> | 
| 60558 | 2956 | fps_radical r k (a * b) = fps_radical r k a * fps_radical r k b" | 
| 2957 | (is "?lhs \<longleftrightarrow> ?rhs") | |
| 2958 | proof | |
| 2959 | show ?rhs if r0': ?lhs | |
| 2960 | proof - | |
| 2961 | from r0' have r0: "(r k ((a * b) $ 0)) ^ k = (a * b) $ 0" | |
| 52903 | 2962 | by (simp add: fps_mult_nth ra0 rb0 power_mult_distrib) | 
| 60558 | 2963 | show ?thesis | 
| 60501 | 2964 | proof (cases k) | 
| 2965 | case 0 | |
| 2966 | then show ?thesis using r0' by simp | |
| 2967 | next | |
| 2968 | case (Suc h) | |
| 52903 | 2969 | let ?ra = "fps_radical r (Suc h) a" | 
| 2970 | let ?rb = "fps_radical r (Suc h) b" | |
| 2971 | have th0: "r (Suc h) ((a * b) $ 0) = (fps_radical r (Suc h) a * fps_radical r (Suc h) b) $ 0" | |
| 60501 | 2972 | using r0' Suc by (simp add: fps_mult_nth) | 
| 52903 | 2973 | have ab0: "(a*b) $ 0 \<noteq> 0" | 
| 2974 | using a0 b0 by (simp add: fps_mult_nth) | |
| 60501 | 2975 | from radical_unique[of r h "a*b" "fps_radical r (Suc h) a * fps_radical r (Suc h) b", OF r0[unfolded Suc] th0 ab0, symmetric] | 
| 2976 | iffD1[OF power_radical[of _ r], OF a0 ra0[unfolded Suc]] iffD1[OF power_radical[of _ r], OF b0 rb0[unfolded Suc]] Suc r0' | |
| 2977 | show ?thesis | |
| 2978 | by (auto simp add: power_mult_distrib simp del: power_Suc) | |
| 2979 | qed | |
| 60558 | 2980 | qed | 
| 2981 | show ?lhs if ?rhs | |
| 2982 | proof - | |
| 2983 | from that have "(fps_radical r k (a * b)) $ 0 = (fps_radical r k a * fps_radical r k b) $ 0" | |
| 52903 | 2984 | by simp | 
| 60558 | 2985 | then show ?thesis | 
| 52903 | 2986 | using k by (simp add: fps_mult_nth) | 
| 60558 | 2987 | qed | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2988 | qed | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2989 | |
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2990 | (* | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2991 | lemma radical_mult_distrib: | 
| 31273 | 2992 | fixes a:: "'a::field_char_0 fps" | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2993 | assumes | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2994 | ra0: "r k (a $ 0) ^ k = a $ 0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2995 | and rb0: "r k (b $ 0) ^ k = b $ 0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2996 | and r0': "r k ((a * b) $ 0) = r k (a $ 0) * r k (b $ 0)" | 
| 29687 | 2997 | and a0: "a$0 \<noteq> 0" | 
| 2998 | and b0: "b$0 \<noteq> 0" | |
| 2999 | shows "fps_radical r (k) (a*b) = fps_radical r (k) a * fps_radical r (k) (b)" | |
| 3000 | proof- | |
| 3001 | from r0' have r0: "(r (k) ((a*b)$0)) ^ k = (a*b)$0" | |
| 3002 | by (simp add: fps_mult_nth ra0 rb0 power_mult_distrib) | |
| 54452 | 3003 |   {assume "k=0" then have ?thesis by simp}
 | 
| 29687 | 3004 | moreover | 
| 3005 |   {fix h assume k: "k = Suc h"
 | |
| 3006 | let ?ra = "fps_radical r (Suc h) a" | |
| 3007 | let ?rb = "fps_radical r (Suc h) b" | |
| 30488 | 3008 | have th0: "r (Suc h) ((a * b) $ 0) = (fps_radical r (Suc h) a * fps_radical r (Suc h) b) $ 0" | 
| 29687 | 3009 | using r0' k by (simp add: fps_mult_nth) | 
| 3010 | have ab0: "(a*b) $ 0 \<noteq> 0" using a0 b0 by (simp add: fps_mult_nth) | |
| 30488 | 3011 | from radical_unique[of r h "a*b" "fps_radical r (Suc h) a * fps_radical r (Suc h) b", OF r0[unfolded k] th0 ab0, symmetric] | 
| 29687 | 3012 | power_radical[of r, OF ra0[unfolded k] a0] power_radical[of r, OF rb0[unfolded k] b0] k | 
| 30273 
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
 huffman parents: 
29915diff
changeset | 3013 | have ?thesis by (auto simp add: power_mult_distrib simp del: power_Suc)} | 
| 29687 | 3014 | ultimately show ?thesis by (cases k, auto) | 
| 3015 | qed | |
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 3016 | *) | 
| 29687 | 3017 | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 3018 | lemma fps_divide_1 [simp]: "(a :: 'a::field fps) / 1 = a" | 
| 64240 | 3019 | by (fact div_by_1) | 
| 29687 | 3020 | |
| 3021 | lemma radical_divide: | |
| 31273 | 3022 | fixes a :: "'a::field_char_0 fps" | 
| 52903 | 3023 | assumes kp: "k > 0" | 
| 3024 | and ra0: "(r k (a $ 0)) ^ k = a $ 0" | |
| 3025 | and rb0: "(r k (b $ 0)) ^ k = b $ 0" | |
| 3026 | and a0: "a$0 \<noteq> 0" | |
| 3027 | and b0: "b$0 \<noteq> 0" | |
| 3028 | shows "r k ((a $ 0) / (b$0)) = r k (a$0) / r k (b $ 0) \<longleftrightarrow> | |
| 3029 | fps_radical r k (a/b) = fps_radical r k a / fps_radical r k b" | |
| 3030 | (is "?lhs = ?rhs") | |
| 60501 | 3031 | proof | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 3032 | let ?r = "fps_radical r k" | 
| 60558 | 3033 | from kp obtain h where k: "k = Suc h" | 
| 3034 | by (cases k) auto | |
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 3035 | have ra0': "r k (a$0) \<noteq> 0" using a0 ra0 k by auto | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 3036 | have rb0': "r k (b$0) \<noteq> 0" using b0 rb0 k by auto | 
| 30488 | 3037 | |
| 60501 | 3038 | show ?lhs if ?rhs | 
| 3039 | proof - | |
| 3040 | from that have "?r (a/b) $ 0 = (?r a / ?r b)$0" | |
| 3041 | by simp | |
| 3042 | then show ?thesis | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 3043 | using k a0 b0 rb0' by (simp add: fps_divide_unit fps_mult_nth fps_inverse_def divide_inverse) | 
| 60501 | 3044 | qed | 
| 3045 | show ?rhs if ?lhs | |
| 3046 | proof - | |
| 52891 | 3047 | from a0 b0 have ab0[simp]: "(a/b)$0 = a$0 / b$0" | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 3048 | by (simp add: fps_divide_def fps_mult_nth divide_inverse fps_inverse_def) | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 3049 | have th0: "r k ((a/b)$0) ^ k = (a/b)$0" | 
| 60867 | 3050 | by (simp add: \<open>?lhs\<close> power_divide ra0 rb0) | 
| 60501 | 3051 | from a0 b0 ra0' rb0' kp \<open>?lhs\<close> | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 3052 | have th1: "r k ((a / b) $ 0) = (fps_radical r k a / fps_radical r k b) $ 0" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 3053 | by (simp add: fps_divide_unit fps_mult_nth fps_inverse_def divide_inverse) | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 3054 | from a0 b0 ra0' rb0' kp have ab0': "(a / b) $ 0 \<noteq> 0" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 3055 | by (simp add: fps_divide_unit fps_mult_nth fps_inverse_def nonzero_imp_inverse_nonzero) | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 3056 | note tha[simp] = iffD1[OF power_radical[where r=r and k=h], OF a0 ra0[unfolded k], unfolded k[symmetric]] | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 3057 | note thb[simp] = iffD1[OF power_radical[where r=r and k=h], OF b0 rb0[unfolded k], unfolded k[symmetric]] | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 3058 | from b0 rb0' have th2: "(?r a / ?r b)^k = a/b" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 3059 | by (simp add: fps_divide_unit power_mult_distrib fps_inverse_power[symmetric]) | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 3060 | |
| 52902 | 3061 | from iffD1[OF radical_unique[where r=r and a="?r a / ?r b" and b="a/b" and k=h], symmetric, unfolded k[symmetric], OF th0 th1 ab0' th2] | 
| 60501 | 3062 | show ?thesis . | 
| 3063 | qed | |
| 29687 | 3064 | qed | 
| 3065 | ||
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 3066 | lemma radical_inverse: | 
| 31273 | 3067 | fixes a :: "'a::field_char_0 fps" | 
| 52903 | 3068 | assumes k: "k > 0" | 
| 3069 | and ra0: "r k (a $ 0) ^ k = a $ 0" | |
| 3070 | and r1: "(r k 1)^k = 1" | |
| 3071 | and a0: "a$0 \<noteq> 0" | |
| 53196 | 3072 | shows "r k (inverse (a $ 0)) = r k 1 / (r k (a $ 0)) \<longleftrightarrow> | 
| 3073 | fps_radical r k (inverse a) = fps_radical r k 1 / fps_radical r k a" | |
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 3074 | using radical_divide[where k=k and r=r and a=1 and b=a, OF k ] ra0 r1 a0 | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 3075 | by (simp add: divide_inverse fps_divide_def) | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 3076 | |
| 60501 | 3077 | |
| 3078 | subsection \<open>Derivative of composition\<close> | |
| 29687 | 3079 | |
| 30488 | 3080 | lemma fps_compose_deriv: | 
| 54681 | 3081 | fixes a :: "'a::idom fps" | 
| 29687 | 3082 | assumes b0: "b$0 = 0" | 
| 54681 | 3083 | shows "fps_deriv (a oo b) = ((fps_deriv a) oo b) * fps_deriv b" | 
| 52903 | 3084 | proof - | 
| 60501 | 3085 | have "(fps_deriv (a oo b))$n = (((fps_deriv a) oo b) * (fps_deriv b)) $n" for n | 
| 3086 | proof - | |
| 64267 | 3087 |     have "(fps_deriv (a oo b))$n = sum (\<lambda>i. a $ i * (fps_deriv (b^i))$n) {0.. Suc n}"
 | 
| 3088 | by (simp add: fps_compose_def field_simps sum_distrib_left del: of_nat_Suc) | |
| 3089 |     also have "\<dots> = sum (\<lambda>i. a$i * ((fps_const (of_nat i)) * (fps_deriv b * (b^(i - 1))))$n) {0.. Suc n}"
 | |
| 36350 | 3090 | by (simp add: field_simps fps_deriv_power del: fps_mult_left_const_nth of_nat_Suc) | 
| 64267 | 3091 |     also have "\<dots> = sum (\<lambda>i. of_nat i * a$i * (((b^(i - 1)) * fps_deriv b))$n) {0.. Suc n}"
 | 
| 52903 | 3092 | unfolding fps_mult_left_const_nth by (simp add: field_simps) | 
| 64267 | 3093 |     also have "\<dots> = sum (\<lambda>i. of_nat i * a$i * (sum (\<lambda>j. (b^ (i - 1))$j * (fps_deriv b)$(n - j)) {0..n})) {0.. Suc n}"
 | 
| 52903 | 3094 | unfolding fps_mult_nth .. | 
| 64267 | 3095 |     also have "\<dots> = sum (\<lambda>i. of_nat i * a$i * (sum (\<lambda>j. (b^ (i - 1))$j * (fps_deriv b)$(n - j)) {0..n})) {1.. Suc n}"
 | 
| 3096 | apply (rule sum.mono_neutral_right) | |
| 3097 | apply (auto simp add: mult_delta_left sum.delta not_le) | |
| 52903 | 3098 | done | 
| 64267 | 3099 |     also have "\<dots> = sum (\<lambda>i. of_nat (i + 1) * a$(i+1) * (sum (\<lambda>j. (b^ i)$j * of_nat (n - j + 1) * b$(n - j + 1)) {0..n})) {0.. n}"
 | 
| 52903 | 3100 | unfolding fps_deriv_nth | 
| 64267 | 3101 | by (rule sum.reindex_cong [of Suc]) (auto simp add: mult.assoc) | 
| 52903 | 3102 | finally have th0: "(fps_deriv (a oo b))$n = | 
| 64267 | 3103 |       sum (\<lambda>i. of_nat (i + 1) * a$(i+1) * (sum (\<lambda>j. (b^ i)$j * of_nat (n - j + 1) * b$(n - j + 1)) {0..n})) {0.. n}" .
 | 
| 3104 | ||
| 3105 |     have "(((fps_deriv a) oo b) * (fps_deriv b))$n = sum (\<lambda>i. (fps_deriv b)$ (n - i) * ((fps_deriv a) oo b)$i) {0..n}"
 | |
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 3106 | unfolding fps_mult_nth by (simp add: ac_simps) | 
| 64267 | 3107 |     also have "\<dots> = sum (\<lambda>i. sum (\<lambda>j. of_nat (n - i +1) * b$(n - i + 1) * of_nat (j + 1) * a$(j+1) * (b^j)$i) {0..n}) {0..n}"
 | 
| 3108 | unfolding fps_deriv_nth fps_compose_nth sum_distrib_left mult.assoc | |
| 3109 | apply (rule sum.cong) | |
| 57418 | 3110 | apply (rule refl) | 
| 64267 | 3111 | apply (rule sum.mono_neutral_left) | 
| 52903 | 3112 | apply (simp_all add: subset_eq) | 
| 3113 | apply clarify | |
| 3114 | apply (subgoal_tac "b^i$x = 0") | |
| 3115 | apply simp | |
| 3116 | apply (rule startsby_zero_power_prefix[OF b0, rule_format]) | |
| 3117 | apply simp | |
| 3118 | done | |
| 64267 | 3119 |     also have "\<dots> = sum (\<lambda>i. of_nat (i + 1) * a$(i+1) * (sum (\<lambda>j. (b^ i)$j * of_nat (n - j + 1) * b$(n - j + 1)) {0..n})) {0.. n}"
 | 
| 3120 | unfolding sum_distrib_left | |
| 3121 | apply (subst sum.commute) | |
| 3122 | apply (rule sum.cong, rule refl)+ | |
| 52903 | 3123 | apply simp | 
| 3124 | done | |
| 60501 | 3125 | finally show ?thesis | 
| 52903 | 3126 | unfolding th0 by simp | 
| 60501 | 3127 | qed | 
| 52903 | 3128 | then show ?thesis by (simp add: fps_eq_iff) | 
| 29687 | 3129 | qed | 
| 3130 | ||
| 3131 | lemma fps_mult_X_plus_1_nth: | |
| 3132 | "((1+X)*a) $n = (if n = 0 then (a$n :: 'a::comm_ring_1) else a$n + a$(n - 1))" | |
| 52903 | 3133 | proof (cases n) | 
| 3134 | case 0 | |
| 54681 | 3135 | then show ?thesis | 
| 60501 | 3136 | by (simp add: fps_mult_nth) | 
| 52903 | 3137 | next | 
| 3138 | case (Suc m) | |
| 64267 | 3139 |   have "((1 + X)*a) $ n = sum (\<lambda>i. (1 + X) $ i * a $ (n - i)) {0..n}"
 | 
| 52903 | 3140 | by (simp add: fps_mult_nth) | 
| 64267 | 3141 |   also have "\<dots> = sum (\<lambda>i. (1+X)$i * a$(n-i)) {0.. 1}"
 | 
| 3142 | unfolding Suc by (rule sum.mono_neutral_right) auto | |
| 52903 | 3143 | also have "\<dots> = (if n = 0 then (a$n :: 'a::comm_ring_1) else a$n + a$(n - 1))" | 
| 3144 | by (simp add: Suc) | |
| 3145 | finally show ?thesis . | |
| 29687 | 3146 | qed | 
| 3147 | ||
| 54681 | 3148 | |
| 60500 | 3149 | subsection \<open>Finite FPS (i.e. polynomials) and X\<close> | 
| 52903 | 3150 | |
| 29687 | 3151 | lemma fps_poly_sum_X: | 
| 60501 | 3152 | assumes "\<forall>i > n. a$i = (0::'a::comm_ring_1)" | 
| 64267 | 3153 |   shows "a = sum (\<lambda>i. fps_const (a$i) * X^i) {0..n}" (is "a = ?r")
 | 
| 52903 | 3154 | proof - | 
| 60501 | 3155 | have "a$i = ?r$i" for i | 
| 64267 | 3156 | unfolding fps_sum_nth fps_mult_left_const_nth X_power_nth | 
| 3157 | by (simp add: mult_delta_right sum.delta' assms) | |
| 60501 | 3158 | then show ?thesis | 
| 3159 | unfolding fps_eq_iff by blast | |
| 29687 | 3160 | qed | 
| 3161 | ||
| 52903 | 3162 | |
| 60501 | 3163 | subsection \<open>Compositional inverses\<close> | 
| 29687 | 3164 | |
| 54681 | 3165 | fun compinv :: "'a fps \<Rightarrow> nat \<Rightarrow> 'a::field" | 
| 52903 | 3166 | where | 
| 29687 | 3167 | "compinv a 0 = X$0" | 
| 52903 | 3168 | | "compinv a (Suc n) = | 
| 64267 | 3169 |     (X$ Suc n - sum (\<lambda>i. (compinv a i) * (a^i)$Suc n) {0 .. n}) / (a$1) ^ Suc n"
 | 
| 29687 | 3170 | |
| 3171 | definition "fps_inv a = Abs_fps (compinv a)" | |
| 3172 | ||
| 52903 | 3173 | lemma fps_inv: | 
| 3174 | assumes a0: "a$0 = 0" | |
| 3175 | and a1: "a$1 \<noteq> 0" | |
| 29687 | 3176 | shows "fps_inv a oo a = X" | 
| 52903 | 3177 | proof - | 
| 29687 | 3178 | let ?i = "fps_inv a oo a" | 
| 60501 | 3179 | have "?i $n = X$n" for n | 
| 3180 | proof (induct n rule: nat_less_induct) | |
| 52903 | 3181 | fix n | 
| 60501 | 3182 | assume h: "\<forall>m<n. ?i$m = X$m" | 
| 3183 | show "?i $ n = X$n" | |
| 3184 | proof (cases n) | |
| 3185 | case 0 | |
| 3186 | then show ?thesis using a0 | |
| 3187 | by (simp add: fps_compose_nth fps_inv_def) | |
| 3188 | next | |
| 3189 | case (Suc n1) | |
| 64267 | 3190 |       have "?i $ n = sum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1} + fps_inv a $ Suc n1 * (a $ 1)^ Suc n1"
 | 
| 60501 | 3191 | by (simp only: fps_compose_nth) (simp add: Suc startsby_zero_power_nth_same [OF a0] del: power_Suc) | 
| 64267 | 3192 |       also have "\<dots> = sum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1} +
 | 
| 3193 |         (X$ Suc n1 - sum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1})"
 | |
| 60501 | 3194 | using a0 a1 Suc by (simp add: fps_inv_def) | 
| 3195 | also have "\<dots> = X$n" using Suc by simp | |
| 3196 | finally show ?thesis . | |
| 52903 | 3197 | qed | 
| 60501 | 3198 | qed | 
| 3199 | then show ?thesis | |
| 3200 | by (simp add: fps_eq_iff) | |
| 29687 | 3201 | qed | 
| 3202 | ||
| 3203 | ||
| 54681 | 3204 | fun gcompinv :: "'a fps \<Rightarrow> 'a fps \<Rightarrow> nat \<Rightarrow> 'a::field" | 
| 52903 | 3205 | where | 
| 29687 | 3206 | "gcompinv b a 0 = b$0" | 
| 52903 | 3207 | | "gcompinv b a (Suc n) = | 
| 64267 | 3208 |     (b$ Suc n - sum (\<lambda>i. (gcompinv b a i) * (a^i)$Suc n) {0 .. n}) / (a$1) ^ Suc n"
 | 
| 29687 | 3209 | |
| 3210 | definition "fps_ginv b a = Abs_fps (gcompinv b a)" | |
| 3211 | ||
| 52903 | 3212 | lemma fps_ginv: | 
| 3213 | assumes a0: "a$0 = 0" | |
| 3214 | and a1: "a$1 \<noteq> 0" | |
| 29687 | 3215 | shows "fps_ginv b a oo a = b" | 
| 52903 | 3216 | proof - | 
| 29687 | 3217 | let ?i = "fps_ginv b a oo a" | 
| 60501 | 3218 | have "?i $n = b$n" for n | 
| 3219 | proof (induct n rule: nat_less_induct) | |
| 52903 | 3220 | fix n | 
| 60501 | 3221 | assume h: "\<forall>m<n. ?i$m = b$m" | 
| 3222 | show "?i $ n = b$n" | |
| 3223 | proof (cases n) | |
| 3224 | case 0 | |
| 3225 | then show ?thesis using a0 | |
| 3226 | by (simp add: fps_compose_nth fps_ginv_def) | |
| 3227 | next | |
| 3228 | case (Suc n1) | |
| 64267 | 3229 |       have "?i $ n = sum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1} + fps_ginv b a $ Suc n1 * (a $ 1)^ Suc n1"
 | 
| 60501 | 3230 | by (simp only: fps_compose_nth) (simp add: Suc startsby_zero_power_nth_same [OF a0] del: power_Suc) | 
| 64267 | 3231 |       also have "\<dots> = sum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1} +
 | 
| 3232 |         (b$ Suc n1 - sum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1})"
 | |
| 60501 | 3233 | using a0 a1 Suc by (simp add: fps_ginv_def) | 
| 3234 | also have "\<dots> = b$n" using Suc by simp | |
| 3235 | finally show ?thesis . | |
| 52903 | 3236 | qed | 
| 60501 | 3237 | qed | 
| 3238 | then show ?thesis | |
| 3239 | by (simp add: fps_eq_iff) | |
| 29687 | 3240 | qed | 
| 3241 | ||
| 3242 | lemma fps_inv_ginv: "fps_inv = fps_ginv X" | |
| 39302 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 nipkow parents: 
39198diff
changeset | 3243 | apply (auto simp add: fun_eq_iff fps_eq_iff fps_inv_def fps_ginv_def) | 
| 48757 | 3244 | apply (induct_tac n rule: nat_less_induct) | 
| 3245 | apply auto | |
| 29687 | 3246 | apply (case_tac na) | 
| 3247 | apply simp | |
| 3248 | apply simp | |
| 3249 | done | |
| 3250 | ||
| 3251 | lemma fps_compose_1[simp]: "1 oo a = 1" | |
| 64267 | 3252 | by (simp add: fps_eq_iff fps_compose_nth mult_delta_left sum.delta) | 
| 29687 | 3253 | |
| 3254 | lemma fps_compose_0[simp]: "0 oo a = 0" | |
| 29913 | 3255 | by (simp add: fps_eq_iff fps_compose_nth) | 
| 29687 | 3256 | |
| 60867 | 3257 | lemma fps_compose_0_right[simp]: "a oo 0 = fps_const (a $ 0)" | 
| 64267 | 3258 | by (auto simp add: fps_eq_iff fps_compose_nth power_0_left sum.neutral) | 
| 29687 | 3259 | |
| 3260 | lemma fps_compose_add_distrib: "(a + b) oo c = (a oo c) + (b oo c)" | |
| 64267 | 3261 | by (simp add: fps_eq_iff fps_compose_nth field_simps sum.distrib) | 
| 3262 | ||
| 3263 | lemma fps_compose_sum_distrib: "(sum f S) oo a = sum (\<lambda>i. f i oo a) S" | |
| 52903 | 3264 | proof (cases "finite S") | 
| 3265 | case True | |
| 3266 | show ?thesis | |
| 3267 | proof (rule finite_induct[OF True]) | |
| 64267 | 3268 |     show "sum f {} oo a = (\<Sum>i\<in>{}. f i oo a)"
 | 
| 60501 | 3269 | by simp | 
| 52903 | 3270 | next | 
| 3271 | fix x F | |
| 3272 | assume fF: "finite F" | |
| 3273 | and xF: "x \<notin> F" | |
| 64267 | 3274 | and h: "sum f F oo a = sum (\<lambda>i. f i oo a) F" | 
| 3275 | show "sum f (insert x F) oo a = sum (\<lambda>i. f i oo a) (insert x F)" | |
| 52903 | 3276 | using fF xF h by (simp add: fps_compose_add_distrib) | 
| 3277 | qed | |
| 3278 | next | |
| 3279 | case False | |
| 3280 | then show ?thesis by simp | |
| 29687 | 3281 | qed | 
| 3282 | ||
| 30488 | 3283 | lemma convolution_eq: | 
| 64267 | 3284 |   "sum (\<lambda>i. a (i :: nat) * b (n - i)) {0 .. n} =
 | 
| 3285 |     sum (\<lambda>(i,j). a i * b j) {(i,j). i \<le> n \<and> j \<le> n \<and> i + j = n}"
 | |
| 3286 | by (rule sum.reindex_bij_witness[where i=fst and j="\<lambda>i. (i, n - i)"]) auto | |
| 29687 | 3287 | |
| 3288 | lemma product_composition_lemma: | |
| 52903 | 3289 | assumes c0: "c$0 = (0::'a::idom)" | 
| 3290 | and d0: "d$0 = 0" | |
| 3291 | shows "((a oo c) * (b oo d))$n = | |
| 64267 | 3292 |     sum (\<lambda>(k,m). a$k * b$m * (c^k * d^m) $ n) {(k,m). k + m \<le> n}"  (is "?l = ?r")
 | 
| 52903 | 3293 | proof - | 
| 54681 | 3294 |   let ?S = "{(k::nat, m::nat). k + m \<le> n}"
 | 
| 61943 | 3295 |   have s: "?S \<subseteq> {0..n} \<times> {0..n}" by (auto simp add: subset_eq)
 | 
| 54681 | 3296 |   have f: "finite {(k::nat, m::nat). k + m \<le> n}"
 | 
| 29687 | 3297 | apply (rule finite_subset[OF s]) | 
| 52903 | 3298 | apply auto | 
| 3299 | done | |
| 64267 | 3300 |   have "?r =  sum (\<lambda>i. sum (\<lambda>(k,m). a$k * (c^k)$i * b$m * (d^m) $ (n - i)) {(k,m). k + m \<le> n}) {0..n}"
 | 
| 3301 | apply (simp add: fps_mult_nth sum_distrib_left) | |
| 3302 | apply (subst sum.commute) | |
| 3303 | apply (rule sum.cong) | |
| 52903 | 3304 | apply (auto simp add: field_simps) | 
| 3305 | done | |
| 30488 | 3306 | also have "\<dots> = ?l" | 
| 64267 | 3307 | apply (simp add: fps_mult_nth fps_compose_nth sum_product) | 
| 3308 | apply (rule sum.cong) | |
| 57418 | 3309 | apply (rule refl) | 
| 64267 | 3310 | apply (simp add: sum.cartesian_product mult.assoc) | 
| 3311 | apply (rule sum.mono_neutral_right[OF f]) | |
| 54452 | 3312 | apply (simp add: subset_eq) | 
| 3313 | apply presburger | |
| 29687 | 3314 | apply clarsimp | 
| 3315 | apply (rule ccontr) | |
| 3316 | apply (clarsimp simp add: not_le) | |
| 3317 | apply (case_tac "x < aa") | |
| 3318 | apply simp | |
| 3319 | apply (frule_tac startsby_zero_power_prefix[rule_format, OF c0]) | |
| 3320 | apply blast | |
| 3321 | apply simp | |
| 3322 | apply (frule_tac startsby_zero_power_prefix[rule_format, OF d0]) | |
| 3323 | apply blast | |
| 3324 | done | |
| 3325 | finally show ?thesis by simp | |
| 3326 | qed | |
| 3327 | ||
| 3328 | lemma product_composition_lemma': | |
| 52903 | 3329 | assumes c0: "c$0 = (0::'a::idom)" | 
| 3330 | and d0: "d$0 = 0" | |
| 3331 | shows "((a oo c) * (b oo d))$n = | |
| 64267 | 3332 |     sum (\<lambda>k. sum (\<lambda>m. a$k * b$m * (c^k * d^m) $ n) {0..n}) {0..n}"  (is "?l = ?r")
 | 
| 29687 | 3333 | unfolding product_composition_lemma[OF c0 d0] | 
| 64267 | 3334 | unfolding sum.cartesian_product | 
| 3335 | apply (rule sum.mono_neutral_left) | |
| 29687 | 3336 | apply simp | 
| 3337 | apply (clarsimp simp add: subset_eq) | |
| 3338 | apply clarsimp | |
| 3339 | apply (rule ccontr) | |
| 3340 | apply (subgoal_tac "(c^aa * d^ba) $ n = 0") | |
| 3341 | apply simp | |
| 3342 | unfolding fps_mult_nth | |
| 64267 | 3343 | apply (rule sum.neutral) | 
| 29687 | 3344 | apply (clarsimp simp add: not_le) | 
| 51489 | 3345 | apply (case_tac "x < aa") | 
| 29687 | 3346 | apply (rule startsby_zero_power_prefix[OF c0, rule_format]) | 
| 3347 | apply simp | |
| 51489 | 3348 | apply (subgoal_tac "n - x < ba") | 
| 29687 | 3349 | apply (frule_tac k = "ba" in startsby_zero_power_prefix[OF d0, rule_format]) | 
| 3350 | apply simp | |
| 3351 | apply arith | |
| 3352 | done | |
| 30488 | 3353 | |
| 29687 | 3354 | |
| 64267 | 3355 | lemma sum_pair_less_iff: | 
| 3356 |   "sum (\<lambda>((k::nat),m). a k * b m * c (k + m)) {(k,m). k + m \<le> n} =
 | |
| 3357 |     sum (\<lambda>s. sum (\<lambda>i. a i * b (s - i) * c s) {0..s}) {0..n}"
 | |
| 52903 | 3358 | (is "?l = ?r") | 
| 3359 | proof - | |
| 3360 |   let ?KM = "{(k,m). k + m \<le> n}"
 | |
| 54452 | 3361 |   let ?f = "\<lambda>s. UNION {(0::nat)..s} (\<lambda>i. {(i,s - i)})"
 | 
| 29687 | 3362 |   have th0: "?KM = UNION {0..n} ?f"
 | 
| 62343 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62102diff
changeset | 3363 | by auto | 
| 29687 | 3364 | show "?l = ?r " | 
| 3365 | unfolding th0 | |
| 64267 | 3366 | apply (subst sum.UNION_disjoint) | 
| 29687 | 3367 | apply auto | 
| 64267 | 3368 | apply (subst sum.UNION_disjoint) | 
| 29687 | 3369 | apply auto | 
| 3370 | done | |
| 3371 | qed | |
| 3372 | ||
| 3373 | lemma fps_compose_mult_distrib_lemma: | |
| 3374 | assumes c0: "c$0 = (0::'a::idom)" | |
| 64267 | 3375 |   shows "((a oo c) * (b oo c))$n = sum (\<lambda>s. sum (\<lambda>i. a$i * b$(s - i) * (c^s) $ n) {0..s}) {0..n}"
 | 
| 29687 | 3376 | unfolding product_composition_lemma[OF c0 c0] power_add[symmetric] | 
| 64267 | 3377 | unfolding sum_pair_less_iff[where a = "\<lambda>k. a$k" and b="\<lambda>m. b$m" and c="\<lambda>s. (c ^ s)$n" and n = n] .. | 
| 29687 | 3378 | |
| 30488 | 3379 | lemma fps_compose_mult_distrib: | 
| 54489 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54452diff
changeset | 3380 | assumes c0: "c $ 0 = (0::'a::idom)" | 
| 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54452diff
changeset | 3381 | shows "(a * b) oo c = (a oo c) * (b oo c)" | 
| 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54452diff
changeset | 3382 | apply (simp add: fps_eq_iff fps_compose_mult_distrib_lemma [OF c0]) | 
| 64267 | 3383 | apply (simp add: fps_compose_nth fps_mult_nth sum_distrib_right) | 
| 52903 | 3384 | done | 
| 3385 | ||
| 64272 | 3386 | lemma fps_compose_prod_distrib: | 
| 29687 | 3387 | assumes c0: "c$0 = (0::'a::idom)" | 
| 64272 | 3388 | shows "prod a S oo c = prod (\<lambda>k. a k oo c) S" | 
| 29687 | 3389 | apply (cases "finite S") | 
| 3390 | apply simp_all | |
| 3391 | apply (induct S rule: finite_induct) | |
| 3392 | apply simp | |
| 3393 | apply (simp add: fps_compose_mult_distrib[OF c0]) | |
| 3394 | done | |
| 3395 | ||
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3396 | lemma fps_compose_divide: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3397 | assumes [simp]: "g dvd f" "h $ 0 = 0" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3398 | shows "fps_compose f h = fps_compose (f / g :: 'a :: field fps) h * fps_compose g h" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3399 | proof - | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3400 | have "f = (f / g) * g" by simp | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3401 | also have "fps_compose \<dots> h = fps_compose (f / g) h * fps_compose g h" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3402 | by (subst fps_compose_mult_distrib) simp_all | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3403 | finally show ?thesis . | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3404 | qed | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3405 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3406 | lemma fps_compose_divide_distrib: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3407 | assumes "g dvd f" "h $ 0 = 0" "fps_compose g h \<noteq> 0" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3408 | shows "fps_compose (f / g :: 'a :: field fps) h = fps_compose f h / fps_compose g h" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3409 | using fps_compose_divide[OF assms(1,2)] assms(3) by simp | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3410 | |
| 53195 | 3411 | lemma fps_compose_power: | 
| 3412 | assumes c0: "c$0 = (0::'a::idom)" | |
| 3413 | shows "(a oo c)^n = a^n oo c" | |
| 52903 | 3414 | proof (cases n) | 
| 3415 | case 0 | |
| 3416 | then show ?thesis by simp | |
| 3417 | next | |
| 3418 | case (Suc m) | |
| 64272 | 3419 |   have th0: "a^n = prod (\<lambda>k. a) {0..m}" "(a oo c) ^ n = prod (\<lambda>k. a oo c) {0..m}"
 | 
| 3420 | by (simp_all add: prod_constant Suc) | |
| 52903 | 3421 | then show ?thesis | 
| 64272 | 3422 | by (simp add: fps_compose_prod_distrib[OF c0]) | 
| 29687 | 3423 | qed | 
| 3424 | ||
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3425 | lemma fps_compose_uminus: "- (a::'a::ring_1 fps) oo c = - (a oo c)" | 
| 64267 | 3426 | by (simp add: fps_eq_iff fps_compose_nth field_simps sum_negf[symmetric]) | 
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3427 | |
| 52903 | 3428 | lemma fps_compose_sub_distrib: "(a - b) oo (c::'a::ring_1 fps) = (a oo c) - (b oo c)" | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53374diff
changeset | 3429 | using fps_compose_add_distrib [of a "- b" c] by (simp add: fps_compose_uminus) | 
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3430 | |
| 52903 | 3431 | lemma X_fps_compose: "X oo a = Abs_fps (\<lambda>n. if n = 0 then (0::'a::comm_ring_1) else a$n)" | 
| 64267 | 3432 | by (simp add: fps_eq_iff fps_compose_nth mult_delta_left sum.delta) | 
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3433 | |
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3434 | lemma fps_inverse_compose: | 
| 52903 | 3435 | assumes b0: "(b$0 :: 'a::field) = 0" | 
| 3436 | and a0: "a$0 \<noteq> 0" | |
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3437 | shows "inverse a oo b = inverse (a oo b)" | 
| 52903 | 3438 | proof - | 
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3439 | let ?ia = "inverse a" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3440 | let ?ab = "a oo b" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3441 | let ?iab = "inverse ?ab" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3442 | |
| 52903 | 3443 | from a0 have ia0: "?ia $ 0 \<noteq> 0" by simp | 
| 3444 | from a0 have ab0: "?ab $ 0 \<noteq> 0" by (simp add: fps_compose_def) | |
| 3445 | have "(?ia oo b) * (a oo b) = 1" | |
| 3446 | unfolding fps_compose_mult_distrib[OF b0, symmetric] | |
| 3447 | unfolding inverse_mult_eq_1[OF a0] | |
| 3448 | fps_compose_1 .. | |
| 54452 | 3449 | |
| 52903 | 3450 | then have "(?ia oo b) * (a oo b) * ?iab = 1 * ?iab" by simp | 
| 3451 | then have "(?ia oo b) * (?iab * (a oo b)) = ?iab" by simp | |
| 3452 | then show ?thesis unfolding inverse_mult_eq_1[OF ab0] by simp | |
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3453 | qed | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3454 | |
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3455 | lemma fps_divide_compose: | 
| 52903 | 3456 | assumes c0: "(c$0 :: 'a::field) = 0" | 
| 3457 | and b0: "b$0 \<noteq> 0" | |
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3458 | shows "(a/b) oo c = (a oo c) / (b oo c)" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 3459 | using b0 c0 by (simp add: fps_divide_unit fps_inverse_compose fps_compose_mult_distrib) | 
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3460 | |
| 52903 | 3461 | lemma gp: | 
| 3462 | assumes a0: "a$0 = (0::'a::field)" | |
| 3463 | shows "(Abs_fps (\<lambda>n. 1)) oo a = 1/(1 - a)" | |
| 3464 | (is "?one oo a = _") | |
| 3465 | proof - | |
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3466 | have o0: "?one $ 0 \<noteq> 0" by simp | 
| 52891 | 3467 | have th0: "(1 - X) $ 0 \<noteq> (0::'a)" by simp | 
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3468 | from fps_inverse_gp[where ?'a = 'a] | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3469 | have "inverse ?one = 1 - X" by (simp add: fps_eq_iff) | 
| 54452 | 3470 | then have "inverse (inverse ?one) = inverse (1 - X)" by simp | 
| 3471 | then have th: "?one = 1/(1 - X)" unfolding fps_inverse_idempotent[OF o0] | |
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3472 | by (simp add: fps_divide_def) | 
| 52903 | 3473 | show ?thesis | 
| 3474 | unfolding th | |
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3475 | unfolding fps_divide_compose[OF a0 th0] | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3476 | fps_compose_1 fps_compose_sub_distrib X_fps_compose_startby0[OF a0] .. | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3477 | qed | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3478 | |
| 52903 | 3479 | lemma fps_const_power [simp]: "fps_const (c::'a::ring_1) ^ n = fps_const (c^n)" | 
| 48757 | 3480 | by (induct n) auto | 
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3481 | |
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3482 | lemma fps_compose_radical: | 
| 31273 | 3483 | assumes b0: "b$0 = (0::'a::field_char_0)" | 
| 52903 | 3484 | and ra0: "r (Suc k) (a$0) ^ Suc k = a$0" | 
| 3485 | and a0: "a$0 \<noteq> 0" | |
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3486 | shows "fps_radical r (Suc k) a oo b = fps_radical r (Suc k) (a oo b)" | 
| 52903 | 3487 | proof - | 
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3488 | let ?r = "fps_radical r (Suc k)" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3489 | let ?ab = "a oo b" | 
| 52903 | 3490 | have ab0: "?ab $ 0 = a$0" | 
| 3491 | by (simp add: fps_compose_def) | |
| 3492 | from ab0 a0 ra0 have rab0: "?ab $ 0 \<noteq> 0" "r (Suc k) (?ab $ 0) ^ Suc k = ?ab $ 0" | |
| 3493 | by simp_all | |
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3494 | have th00: "r (Suc k) ((a oo b) $ 0) = (fps_radical r (Suc k) a oo b) $ 0" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3495 | by (simp add: ab0 fps_compose_def) | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3496 | have th0: "(?r a oo b) ^ (Suc k) = a oo b" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3497 | unfolding fps_compose_power[OF b0] | 
| 52891 | 3498 | unfolding iffD1[OF power_radical[of a r k], OF a0 ra0] .. | 
| 52903 | 3499 | from iffD1[OF radical_unique[where r=r and k=k and b= ?ab and a = "?r a oo b", OF rab0(2) th00 rab0(1)], OF th0] | 
| 3500 | show ?thesis . | |
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3501 | qed | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 3502 | |
| 52903 | 3503 | lemma fps_const_mult_apply_left: "fps_const c * (a oo b) = (fps_const c * a) oo b" | 
| 64267 | 3504 | by (simp add: fps_eq_iff fps_compose_nth sum_distrib_left mult.assoc) | 
| 29687 | 3505 | |
| 3506 | lemma fps_const_mult_apply_right: | |
| 3507 | "(a oo b) * fps_const (c::'a::comm_semiring_1) = (fps_const c * a) oo b" | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 3508 | by (auto simp add: fps_const_mult_apply_left mult.commute) | 
| 29687 | 3509 | |
| 30488 | 3510 | lemma fps_compose_assoc: | 
| 52903 | 3511 | assumes c0: "c$0 = (0::'a::idom)" | 
| 3512 | and b0: "b$0 = 0" | |
| 29687 | 3513 | shows "a oo (b oo c) = a oo b oo c" (is "?l = ?r") | 
| 52903 | 3514 | proof - | 
| 60501 | 3515 | have "?l$n = ?r$n" for n | 
| 3516 | proof - | |
| 64267 | 3517 |     have "?l$n = (sum (\<lambda>i. (fps_const (a$i) * b^i) oo c) {0..n})$n"
 | 
| 52903 | 3518 | by (simp add: fps_compose_nth fps_compose_power[OF c0] fps_const_mult_apply_left | 
| 64267 | 3519 | sum_distrib_left mult.assoc fps_sum_nth) | 
| 3520 |     also have "\<dots> = ((sum (\<lambda>i. fps_const (a$i) * b^i) {0..n}) oo c)$n"
 | |
| 3521 | by (simp add: fps_compose_sum_distrib) | |
| 29687 | 3522 | also have "\<dots> = ?r$n" | 
| 64267 | 3523 | apply (simp add: fps_compose_nth fps_sum_nth sum_distrib_right mult.assoc) | 
| 3524 | apply (rule sum.cong) | |
| 57418 | 3525 | apply (rule refl) | 
| 64267 | 3526 | apply (rule sum.mono_neutral_right) | 
| 29687 | 3527 | apply (auto simp add: not_le) | 
| 52903 | 3528 | apply (erule startsby_zero_power_prefix[OF b0, rule_format]) | 
| 3529 | done | |
| 60501 | 3530 | finally show ?thesis . | 
| 3531 | qed | |
| 3532 | then show ?thesis | |
| 3533 | by (simp add: fps_eq_iff) | |
| 29687 | 3534 | qed | 
| 3535 | ||
| 3536 | ||
| 3537 | lemma fps_X_power_compose: | |
| 52903 | 3538 | assumes a0: "a$0=0" | 
| 54681 | 3539 | shows "X^k oo a = (a::'a::idom fps)^k" | 
| 3540 | (is "?l = ?r") | |
| 52903 | 3541 | proof (cases k) | 
| 3542 | case 0 | |
| 3543 | then show ?thesis by simp | |
| 3544 | next | |
| 53196 | 3545 | case (Suc h) | 
| 60501 | 3546 | have "?l $ n = ?r $n" for n | 
| 3547 | proof - | |
| 3548 | consider "k > n" | "k \<le> n" by arith | |
| 3549 | then show ?thesis | |
| 3550 | proof cases | |
| 3551 | case 1 | |
| 3552 | then show ?thesis | |
| 3553 | using a0 startsby_zero_power_prefix[OF a0] Suc | |
| 52903 | 3554 | by (simp add: fps_compose_nth del: power_Suc) | 
| 60501 | 3555 | next | 
| 3556 | case 2 | |
| 3557 | then show ?thesis | |
| 64267 | 3558 | by (simp add: fps_compose_nth mult_delta_left sum.delta) | 
| 60501 | 3559 | qed | 
| 3560 | qed | |
| 3561 | then show ?thesis | |
| 3562 | unfolding fps_eq_iff by blast | |
| 29687 | 3563 | qed | 
| 3564 | ||
| 52903 | 3565 | lemma fps_inv_right: | 
| 3566 | assumes a0: "a$0 = 0" | |
| 3567 | and a1: "a$1 \<noteq> 0" | |
| 29687 | 3568 | shows "a oo fps_inv a = X" | 
| 52903 | 3569 | proof - | 
| 29687 | 3570 | let ?ia = "fps_inv a" | 
| 3571 | let ?iaa = "a oo fps_inv a" | |
| 60501 | 3572 | have th0: "?ia $ 0 = 0" | 
| 3573 | by (simp add: fps_inv_def) | |
| 3574 | have th1: "?iaa $ 0 = 0" | |
| 3575 | using a0 a1 by (simp add: fps_inv_def fps_compose_nth) | |
| 3576 | have th2: "X$0 = 0" | |
| 3577 | by simp | |
| 3578 | from fps_inv[OF a0 a1] have "a oo (fps_inv a oo a) = a oo X" | |
| 3579 | by simp | |
| 29687 | 3580 | then have "(a oo fps_inv a) oo a = X oo a" | 
| 3581 | by (simp add: fps_compose_assoc[OF a0 th0] X_fps_compose_startby0[OF a0]) | |
| 60501 | 3582 | with fps_compose_inj_right[OF a0 a1] show ?thesis | 
| 3583 | by simp | |
| 29687 | 3584 | qed | 
| 3585 | ||
| 3586 | lemma fps_inv_deriv: | |
| 60501 | 3587 | assumes a0: "a$0 = (0::'a::field)" | 
| 52903 | 3588 | and a1: "a$1 \<noteq> 0" | 
| 29687 | 3589 | shows "fps_deriv (fps_inv a) = inverse (fps_deriv a oo fps_inv a)" | 
| 52903 | 3590 | proof - | 
| 29687 | 3591 | let ?ia = "fps_inv a" | 
| 3592 | let ?d = "fps_deriv a oo ?ia" | |
| 3593 | let ?dia = "fps_deriv ?ia" | |
| 60501 | 3594 | have ia0: "?ia$0 = 0" | 
| 3595 | by (simp add: fps_inv_def) | |
| 3596 | have th0: "?d$0 \<noteq> 0" | |
| 3597 | using a1 by (simp add: fps_compose_nth) | |
| 29687 | 3598 | from fps_inv_right[OF a0 a1] have "?d * ?dia = 1" | 
| 3599 | by (simp add: fps_compose_deriv[OF ia0, of a, symmetric] ) | |
| 60501 | 3600 | then have "inverse ?d * ?d * ?dia = inverse ?d * 1" | 
| 3601 | by simp | |
| 3602 | with inverse_mult_eq_1 [OF th0] show "?dia = inverse ?d" | |
| 3603 | by simp | |
| 29687 | 3604 | qed | 
| 3605 | ||
| 52891 | 3606 | lemma fps_inv_idempotent: | 
| 52903 | 3607 | assumes a0: "a$0 = 0" | 
| 3608 | and a1: "a$1 \<noteq> 0" | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3609 | shows "fps_inv (fps_inv a) = a" | 
| 52903 | 3610 | proof - | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3611 | let ?r = "fps_inv" | 
| 60501 | 3612 | have ra0: "?r a $ 0 = 0" | 
| 3613 | by (simp add: fps_inv_def) | |
| 3614 | from a1 have ra1: "?r a $ 1 \<noteq> 0" | |
| 3615 | by (simp add: fps_inv_def field_simps) | |
| 3616 | have X0: "X$0 = 0" | |
| 3617 | by simp | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3618 | from fps_inv[OF ra0 ra1] have "?r (?r a) oo ?r a = X" . | 
| 60501 | 3619 | then have "?r (?r a) oo ?r a oo a = X oo a" | 
| 3620 | by simp | |
| 52891 | 3621 | then have "?r (?r a) oo (?r a oo a) = a" | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3622 | unfolding X_fps_compose_startby0[OF a0] | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3623 | unfolding fps_compose_assoc[OF a0 ra0, symmetric] . | 
| 60501 | 3624 | then show ?thesis | 
| 3625 | unfolding fps_inv[OF a0 a1] by simp | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3626 | qed | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3627 | |
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3628 | lemma fps_ginv_ginv: | 
| 52903 | 3629 | assumes a0: "a$0 = 0" | 
| 3630 | and a1: "a$1 \<noteq> 0" | |
| 3631 | and c0: "c$0 = 0" | |
| 3632 | and c1: "c$1 \<noteq> 0" | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3633 | shows "fps_ginv b (fps_ginv c a) = b oo a oo fps_inv c" | 
| 52903 | 3634 | proof - | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3635 | let ?r = "fps_ginv" | 
| 60501 | 3636 | from c0 have rca0: "?r c a $0 = 0" | 
| 3637 | by (simp add: fps_ginv_def) | |
| 3638 | from a1 c1 have rca1: "?r c a $ 1 \<noteq> 0" | |
| 3639 | by (simp add: fps_ginv_def field_simps) | |
| 52891 | 3640 | from fps_ginv[OF rca0 rca1] | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3641 | have "?r b (?r c a) oo ?r c a = b" . | 
| 60501 | 3642 | then have "?r b (?r c a) oo ?r c a oo a = b oo a" | 
| 3643 | by simp | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3644 | then have "?r b (?r c a) oo (?r c a oo a) = b oo a" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3645 | apply (subst fps_compose_assoc) | 
| 53195 | 3646 | using a0 c0 | 
| 3647 | apply (auto simp add: fps_ginv_def) | |
| 52903 | 3648 | done | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3649 | then have "?r b (?r c a) oo c = b oo a" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3650 | unfolding fps_ginv[OF a0 a1] . | 
| 60501 | 3651 | then have "?r b (?r c a) oo c oo fps_inv c= b oo a oo fps_inv c" | 
| 3652 | by simp | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3653 | then have "?r b (?r c a) oo (c oo fps_inv c) = b oo a oo fps_inv c" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3654 | apply (subst fps_compose_assoc) | 
| 53195 | 3655 | using a0 c0 | 
| 3656 | apply (auto simp add: fps_inv_def) | |
| 52903 | 3657 | done | 
| 60501 | 3658 | then show ?thesis | 
| 3659 | unfolding fps_inv_right[OF c0 c1] by simp | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3660 | qed | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3661 | |
| 32410 | 3662 | lemma fps_ginv_deriv: | 
| 54681 | 3663 | assumes a0:"a$0 = (0::'a::field)" | 
| 52903 | 3664 | and a1: "a$1 \<noteq> 0" | 
| 32410 | 3665 | shows "fps_deriv (fps_ginv b a) = (fps_deriv b / fps_deriv a) oo fps_ginv X a" | 
| 52903 | 3666 | proof - | 
| 32410 | 3667 | let ?ia = "fps_ginv b a" | 
| 3668 | let ?iXa = "fps_ginv X a" | |
| 3669 | let ?d = "fps_deriv" | |
| 3670 | let ?dia = "?d ?ia" | |
| 60501 | 3671 | have iXa0: "?iXa $ 0 = 0" | 
| 3672 | by (simp add: fps_ginv_def) | |
| 3673 | have da0: "?d a $ 0 \<noteq> 0" | |
| 3674 | using a1 by simp | |
| 3675 | from fps_ginv[OF a0 a1, of b] have "?d (?ia oo a) = fps_deriv b" | |
| 3676 | by simp | |
| 3677 | then have "(?d ?ia oo a) * ?d a = ?d b" | |
| 3678 | unfolding fps_compose_deriv[OF a0] . | |
| 3679 | then have "(?d ?ia oo a) * ?d a * inverse (?d a) = ?d b * inverse (?d a)" | |
| 3680 | by simp | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 3681 | with a1 have "(?d ?ia oo a) * (inverse (?d a) * ?d a) = ?d b / ?d a" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 3682 | by (simp add: fps_divide_unit) | 
| 60501 | 3683 | then have "(?d ?ia oo a) oo ?iXa = (?d b / ?d a) oo ?iXa" | 
| 32410 | 3684 | unfolding inverse_mult_eq_1[OF da0] by simp | 
| 3685 | then have "?d ?ia oo (a oo ?iXa) = (?d b / ?d a) oo ?iXa" | |
| 3686 | unfolding fps_compose_assoc[OF iXa0 a0] . | |
| 3687 | then show ?thesis unfolding fps_inv_ginv[symmetric] | |
| 3688 | unfolding fps_inv_right[OF a0 a1] by simp | |
| 3689 | qed | |
| 3690 | ||
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3691 | lemma fps_compose_linear: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3692 | "fps_compose (f :: 'a :: comm_ring_1 fps) (fps_const c * X) = Abs_fps (\<lambda>n. c^n * f $ n)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3693 | by (simp add: fps_eq_iff fps_compose_def power_mult_distrib | 
| 64267 | 3694 | if_distrib sum.delta' cong: if_cong) | 
| 60501 | 3695 | |
| 3696 | subsection \<open>Elementary series\<close> | |
| 3697 | ||
| 3698 | subsubsection \<open>Exponential series\<close> | |
| 53195 | 3699 | |
| 30488 | 3700 | definition "E x = Abs_fps (\<lambda>n. x^n / of_nat (fact n))" | 
| 29687 | 3701 | |
| 31273 | 3702 | lemma E_deriv[simp]: "fps_deriv (E a) = fps_const (a::'a::field_char_0) * E a" (is "?l = ?r") | 
| 52903 | 3703 | proof - | 
| 60501 | 3704 | have "?l$n = ?r $ n" for n | 
| 3705 | apply (auto simp add: E_def field_simps power_Suc[symmetric] | |
| 63367 
6c731c8b7f03
simplified definitions of combinatorial functions
 haftmann parents: 
63317diff
changeset | 3706 | simp del: fact_Suc of_nat_Suc power_Suc) | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 3707 | apply (simp add: field_simps) | 
| 60501 | 3708 | done | 
| 3709 | then show ?thesis | |
| 3710 | by (simp add: fps_eq_iff) | |
| 29687 | 3711 | qed | 
| 3712 | ||
| 30488 | 3713 | lemma E_unique_ODE: | 
| 54681 | 3714 | "fps_deriv a = fps_const c * a \<longleftrightarrow> a = fps_const (a$0) * E (c::'a::field_char_0)" | 
| 29687 | 3715 | (is "?lhs \<longleftrightarrow> ?rhs") | 
| 52903 | 3716 | proof | 
| 60501 | 3717 | show ?rhs if ?lhs | 
| 3718 | proof - | |
| 3719 | from that have th: "\<And>n. a $ Suc n = c * a$n / of_nat (Suc n)" | |
| 3720 | by (simp add: fps_deriv_def fps_eq_iff field_simps del: of_nat_Suc) | |
| 3721 | have th': "a$n = a$0 * c ^ n/ (fact n)" for n | |
| 3722 | proof (induct n) | |
| 3723 | case 0 | |
| 3724 | then show ?case by simp | |
| 3725 | next | |
| 3726 | case Suc | |
| 3727 | then show ?case | |
| 3728 | unfolding th | |
| 3729 | using fact_gt_zero | |
| 3730 | apply (simp add: field_simps del: of_nat_Suc fact_Suc) | |
| 3731 | apply simp | |
| 3732 | done | |
| 3733 | qed | |
| 3734 | show ?thesis | |
| 3735 | by (auto simp add: fps_eq_iff fps_const_mult_left E_def intro: th') | |
| 3736 | qed | |
| 3737 | show ?lhs if ?rhs | |
| 3738 | using that by (metis E_deriv fps_deriv_mult_const_left mult.left_commute) | |
| 29687 | 3739 | qed | 
| 3740 | ||
| 31273 | 3741 | lemma E_add_mult: "E (a + b) = E (a::'a::field_char_0) * E b" (is "?l = ?r") | 
| 52903 | 3742 | proof - | 
| 60501 | 3743 | have "fps_deriv ?r = fps_const (a + b) * ?r" | 
| 36350 | 3744 | by (simp add: fps_const_add[symmetric] field_simps del: fps_const_add) | 
| 60501 | 3745 | then have "?r = ?l" | 
| 3746 | by (simp only: E_unique_ODE) (simp add: fps_mult_nth E_def) | |
| 29687 | 3747 | then show ?thesis .. | 
| 3748 | qed | |
| 3749 | ||
| 3750 | lemma E_nth[simp]: "E a $ n = a^n / of_nat (fact n)" | |
| 3751 | by (simp add: E_def) | |
| 3752 | ||
| 54681 | 3753 | lemma E0[simp]: "E (0::'a::field) = 1" | 
| 29687 | 3754 | by (simp add: fps_eq_iff power_0_left) | 
| 3755 | ||
| 31273 | 3756 | lemma E_neg: "E (- a) = inverse (E (a::'a::field_char_0))" | 
| 52903 | 3757 | proof - | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 3758 | from E_add_mult[of a "- a"] have th0: "E a * E (- a) = 1" by simp | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 3759 | from fps_inverse_unique[OF th0] show ?thesis by simp | 
| 29687 | 3760 | qed | 
| 3761 | ||
| 31273 | 3762 | lemma E_nth_deriv[simp]: "fps_nth_deriv n (E (a::'a::field_char_0)) = (fps_const a)^n * (E a)" | 
| 52902 | 3763 | by (induct n) auto | 
| 29687 | 3764 | |
| 54681 | 3765 | lemma X_compose_E[simp]: "X oo E (a::'a::field) = E a - 1" | 
| 29687 | 3766 | by (simp add: fps_eq_iff X_fps_compose) | 
| 3767 | ||
| 30488 | 3768 | lemma LE_compose: | 
| 60501 | 3769 | assumes a: "a \<noteq> 0" | 
| 29687 | 3770 | shows "fps_inv (E a - 1) oo (E a - 1) = X" | 
| 52903 | 3771 | and "(E a - 1) oo fps_inv (E a - 1) = X" | 
| 53195 | 3772 | proof - | 
| 29687 | 3773 | let ?b = "E a - 1" | 
| 60501 | 3774 | have b0: "?b $ 0 = 0" | 
| 3775 | by simp | |
| 3776 | have b1: "?b $ 1 \<noteq> 0" | |
| 3777 | by (simp add: a) | |
| 29687 | 3778 | from fps_inv[OF b0 b1] show "fps_inv (E a - 1) oo (E a - 1) = X" . | 
| 3779 | from fps_inv_right[OF b0 b1] show "(E a - 1) oo fps_inv (E a - 1) = X" . | |
| 3780 | qed | |
| 3781 | ||
| 31273 | 3782 | lemma E_power_mult: "(E (c::'a::field_char_0))^n = E (of_nat n * c)" | 
| 52902 | 3783 | by (induct n) (auto simp add: field_simps E_add_mult) | 
| 29687 | 3784 | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3785 | lemma radical_E: | 
| 52891 | 3786 | assumes r: "r (Suc k) 1 = 1" | 
| 54681 | 3787 | shows "fps_radical r (Suc k) (E (c::'a::field_char_0)) = E (c / of_nat (Suc k))" | 
| 52903 | 3788 | proof - | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3789 | let ?ck = "(c / of_nat (Suc k))" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3790 | let ?r = "fps_radical r (Suc k)" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3791 | have eq0[simp]: "?ck * of_nat (Suc k) = c" "of_nat (Suc k) * ?ck = c" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3792 | by (simp_all del: of_nat_Suc) | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3793 | have th0: "E ?ck ^ (Suc k) = E c" unfolding E_power_mult eq0 .. | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3794 | have th: "r (Suc k) (E c $0) ^ Suc k = E c $ 0" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3795 | "r (Suc k) (E c $ 0) = E ?ck $ 0" "E c $ 0 \<noteq> 0" using r by simp_all | 
| 60501 | 3796 | from th0 radical_unique[where r=r and k=k, OF th] show ?thesis | 
| 3797 | by auto | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3798 | qed | 
| 29687 | 3799 | |
| 54681 | 3800 | lemma Ec_E1_eq: "E (1::'a::field_char_0) oo (fps_const c * X) = E c" | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3801 | apply (auto simp add: fps_eq_iff E_def fps_compose_def power_mult_distrib) | 
| 64267 | 3802 | apply (simp add: cond_value_iff cond_application_beta sum.delta' cong del: if_weak_cong) | 
| 52902 | 3803 | done | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3804 | |
| 53195 | 3805 | |
| 60501 | 3806 | subsubsection \<open>Logarithmic series\<close> | 
| 29687 | 3807 | |
| 52891 | 3808 | lemma Abs_fps_if_0: | 
| 60501 | 3809 | "Abs_fps (\<lambda>n. if n = 0 then (v::'a::ring_1) else f n) = | 
| 3810 | fps_const v + X * Abs_fps (\<lambda>n. f (Suc n))" | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3811 | by (auto simp add: fps_eq_iff) | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3812 | |
| 52902 | 3813 | definition L :: "'a::field_char_0 \<Rightarrow> 'a fps" | 
| 3814 | where "L c = fps_const (1/c) * Abs_fps (\<lambda>n. if n = 0 then 0 else (- 1) ^ (n - 1) / of_nat n)" | |
| 29687 | 3815 | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3816 | lemma fps_deriv_L: "fps_deriv (L c) = fps_const (1/c) * inverse (1 + X)" | 
| 60162 | 3817 | unfolding fps_inverse_X_plus1 | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3818 | by (simp add: L_def fps_eq_iff del: of_nat_Suc) | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3819 | |
| 60501 | 3820 | lemma L_nth: "L c $ n = (if n = 0 then 0 else 1/c * ((- 1) ^ (n - 1) / of_nat n))" | 
| 36350 | 3821 | by (simp add: L_def field_simps) | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3822 | |
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3823 | lemma L_0[simp]: "L c $ 0 = 0" by (simp add: L_def) | 
| 52903 | 3824 | |
| 29687 | 3825 | lemma L_E_inv: | 
| 54452 | 3826 | fixes a :: "'a::field_char_0" | 
| 3827 | assumes a: "a \<noteq> 0" | |
| 3828 | shows "L a = fps_inv (E a - 1)" (is "?l = ?r") | |
| 52903 | 3829 | proof - | 
| 29687 | 3830 | let ?b = "E a - 1" | 
| 3831 | have b0: "?b $ 0 = 0" by simp | |
| 3832 | have b1: "?b $ 1 \<noteq> 0" by (simp add: a) | |
| 52903 | 3833 | have "fps_deriv (E a - 1) oo fps_inv (E a - 1) = | 
| 3834 | (fps_const a * (E a - 1) + fps_const a) oo fps_inv (E a - 1)" | |
| 36350 | 3835 | by (simp add: field_simps) | 
| 52903 | 3836 | also have "\<dots> = fps_const a * (X + 1)" | 
| 3837 | apply (simp add: fps_compose_add_distrib fps_const_mult_apply_left[symmetric] fps_inv_right[OF b0 b1]) | |
| 3838 | apply (simp add: field_simps) | |
| 3839 | done | |
| 29687 | 3840 | finally have eq: "fps_deriv (E a - 1) oo fps_inv (E a - 1) = fps_const a * (X + 1)" . | 
| 3841 | from fps_inv_deriv[OF b0 b1, unfolded eq] | |
| 3842 | have "fps_deriv (fps_inv ?b) = fps_const (inverse a) / (X + 1)" | |
| 52891 | 3843 | using a | 
| 29687 | 3844 | by (simp add: fps_const_inverse eq fps_divide_def fps_inverse_mult) | 
| 54452 | 3845 | then have "fps_deriv ?l = fps_deriv ?r" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 3846 | by (simp add: fps_deriv_L add.commute fps_divide_def divide_inverse) | 
| 29687 | 3847 | then show ?thesis unfolding fps_deriv_eq_iff | 
| 3848 | by (simp add: L_nth fps_inv_def) | |
| 3849 | qed | |
| 3850 | ||
| 52891 | 3851 | lemma L_mult_add: | 
| 52903 | 3852 | assumes c0: "c\<noteq>0" | 
| 3853 | and d0: "d\<noteq>0" | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3854 | shows "L c + L d = fps_const (c+d) * L (c*d)" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3855 | (is "?r = ?l") | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3856 | proof- | 
| 36350 | 3857 | from c0 d0 have eq: "1/c + 1/d = (c+d)/(c*d)" by (simp add: field_simps) | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3858 | have "fps_deriv ?r = fps_const (1/c + 1/d) * inverse (1 + X)" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3859 | by (simp add: fps_deriv_L fps_const_add[symmetric] algebra_simps del: fps_const_add) | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3860 | also have "\<dots> = fps_deriv ?l" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3861 | apply (simp add: fps_deriv_L) | 
| 52903 | 3862 | apply (simp add: fps_eq_iff eq) | 
| 3863 | done | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3864 | finally show ?thesis | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3865 | unfolding fps_deriv_eq_iff by simp | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3866 | qed | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 3867 | |
| 53196 | 3868 | |
| 60501 | 3869 | subsubsection \<open>Binomial series\<close> | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3870 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3871 | definition "fps_binomial a = Abs_fps (\<lambda>n. a gchoose n)" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3872 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3873 | lemma fps_binomial_nth[simp]: "fps_binomial a $ n = a gchoose n" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3874 | by (simp add: fps_binomial_def) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3875 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3876 | lemma fps_binomial_ODE_unique: | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3877 | fixes c :: "'a::field_char_0" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3878 | shows "fps_deriv a = (fps_const c * a) / (1 + X) \<longleftrightarrow> a = fps_const (a$0) * fps_binomial c" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3879 | (is "?lhs \<longleftrightarrow> ?rhs") | 
| 60501 | 3880 | proof | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3881 | let ?da = "fps_deriv a" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3882 | let ?x1 = "(1 + X):: 'a fps" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3883 | let ?l = "?x1 * ?da" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3884 | let ?r = "fps_const c * a" | 
| 60501 | 3885 | |
| 3886 | have eq: "?l = ?r \<longleftrightarrow> ?lhs" | |
| 3887 | proof - | |
| 3888 | have x10: "?x1 $ 0 \<noteq> 0" by simp | |
| 3889 | have "?l = ?r \<longleftrightarrow> inverse ?x1 * ?l = inverse ?x1 * ?r" by simp | |
| 3890 | also have "\<dots> \<longleftrightarrow> ?da = (fps_const c * a) / ?x1" | |
| 3891 | apply (simp only: fps_divide_def mult.assoc[symmetric] inverse_mult_eq_1[OF x10]) | |
| 3892 | apply (simp add: field_simps) | |
| 3893 | done | |
| 3894 | finally show ?thesis . | |
| 3895 | qed | |
| 3896 | ||
| 3897 | show ?rhs if ?lhs | |
| 3898 | proof - | |
| 3899 | from eq that have h: "?l = ?r" .. | |
| 3900 | have th0: "a$ Suc n = ((c - of_nat n) / of_nat (Suc n)) * a $n" for n | |
| 3901 | proof - | |
| 3902 | from h have "?l $ n = ?r $ n" by simp | |
| 3903 | then show ?thesis | |
| 36350 | 3904 | apply (simp add: field_simps del: of_nat_Suc) | 
| 60501 | 3905 | apply (cases n) | 
| 3906 | apply (simp_all add: field_simps del: of_nat_Suc) | |
| 3907 | done | |
| 3908 | qed | |
| 3909 | have th1: "a $ n = (c gchoose n) * a $ 0" for n | |
| 3910 | proof (induct n) | |
| 3911 | case 0 | |
| 3912 | then show ?case by simp | |
| 3913 | next | |
| 3914 | case (Suc m) | |
| 3915 | then show ?case | |
| 3916 | unfolding th0 | |
| 3917 | apply (simp add: field_simps del: of_nat_Suc) | |
| 3918 | unfolding mult.assoc[symmetric] gbinomial_mult_1 | |
| 3919 | apply (simp add: field_simps) | |
| 3920 | done | |
| 3921 | qed | |
| 3922 | show ?thesis | |
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3923 | apply (simp add: fps_eq_iff) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3924 | apply (subst th1) | 
| 53196 | 3925 | apply (simp add: field_simps) | 
| 3926 | done | |
| 60501 | 3927 | qed | 
| 3928 | ||
| 3929 | show ?lhs if ?rhs | |
| 3930 | proof - | |
| 3931 | have th00: "x * (a $ 0 * y) = a $ 0 * (x * y)" for x y | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 3932 | by (simp add: mult.commute) | 
| 52891 | 3933 | have "?l = ?r" | 
| 60501 | 3934 | apply (subst \<open>?rhs\<close>) | 
| 3935 | apply (subst (2) \<open>?rhs\<close>) | |
| 36350 | 3936 | apply (clarsimp simp add: fps_eq_iff field_simps) | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 3937 | unfolding mult.assoc[symmetric] th00 gbinomial_mult_1 | 
| 53196 | 3938 | apply (simp add: field_simps gbinomial_mult_1) | 
| 3939 | done | |
| 60501 | 3940 | with eq show ?thesis .. | 
| 3941 | qed | |
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3942 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3943 | |
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3944 | lemma fps_binomial_ODE_unique': | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3945 | "(fps_deriv a = fps_const c * a / (1 + X) \<and> a $ 0 = 1) \<longleftrightarrow> (a = fps_binomial c)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3946 | by (subst fps_binomial_ODE_unique) auto | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3947 | |
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3948 | lemma fps_binomial_deriv: "fps_deriv (fps_binomial c) = fps_const c * fps_binomial c / (1 + X)" | 
| 53196 | 3949 | proof - | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3950 | let ?a = "fps_binomial c" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3951 | have th0: "?a = fps_const (?a$0) * ?a" by (simp) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3952 | from iffD2[OF fps_binomial_ODE_unique, OF th0] show ?thesis . | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3953 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3954 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3955 | lemma fps_binomial_add_mult: "fps_binomial (c+d) = fps_binomial c * fps_binomial d" (is "?l = ?r") | 
| 53196 | 3956 | proof - | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3957 | let ?P = "?r - ?l" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3958 | let ?b = "fps_binomial" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3959 | let ?db = "\<lambda>x. fps_deriv (?b x)" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3960 | have "fps_deriv ?P = ?db c * ?b d + ?b c * ?db d - ?db (c + d)" by simp | 
| 53196 | 3961 | also have "\<dots> = inverse (1 + X) * | 
| 3962 | (fps_const c * ?b c * ?b d + fps_const d * ?b c * ?b d - fps_const (c+d) * ?b (c + d))" | |
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3963 | unfolding fps_binomial_deriv | 
| 36350 | 3964 | by (simp add: fps_divide_def field_simps) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3965 | also have "\<dots> = (fps_const (c + d)/ (1 + X)) * ?P" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 3966 | by (simp add: field_simps fps_divide_unit fps_const_add[symmetric] del: fps_const_add) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3967 | finally have th0: "fps_deriv ?P = fps_const (c+d) * ?P / (1 + X)" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3968 | by (simp add: fps_divide_def) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3969 | have "?P = fps_const (?P$0) * ?b (c + d)" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3970 | unfolding fps_binomial_ODE_unique[symmetric] | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3971 | using th0 by simp | 
| 54452 | 3972 | then have "?P = 0" by (simp add: fps_mult_nth) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3973 | then show ?thesis by simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3974 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3975 | |
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
60867diff
changeset | 3976 | lemma fps_binomial_minus_one: "fps_binomial (- 1) = inverse (1 + X)" | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3977 | (is "?l = inverse ?r") | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3978 | proof- | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3979 | have th: "?r$0 \<noteq> 0" by simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3980 | have th': "fps_deriv (inverse ?r) = fps_const (- 1) * inverse ?r / (1 + X)" | 
| 53196 | 3981 | by (simp add: fps_inverse_deriv[OF th] fps_divide_def | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57418diff
changeset | 3982 | power2_eq_square mult.commute fps_const_neg[symmetric] del: fps_const_neg) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3983 | have eq: "inverse ?r $ 0 = 1" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3984 | by (simp add: fps_inverse_def) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3985 | from iffD1[OF fps_binomial_ODE_unique[of "inverse (1 + X)" "- 1"] th'] eq | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3986 | show ?thesis by (simp add: fps_inverse_def) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3987 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3988 | |
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3989 | lemma fps_binomial_of_nat: "fps_binomial (of_nat n) = (1 + X :: 'a :: field_char_0 fps) ^ n" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3990 | proof (cases "n = 0") | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3991 | case [simp]: True | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3992 | have "fps_deriv ((1 + X) ^ n :: 'a fps) = 0" by simp | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3993 | also have "\<dots> = fps_const (of_nat n) * (1 + X) ^ n / (1 + X)" by (simp add: fps_binomial_def) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3994 | finally show ?thesis by (subst sym, subst fps_binomial_ODE_unique' [symmetric]) simp_all | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3995 | next | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3996 | case False | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3997 | have "fps_deriv ((1 + X) ^ n :: 'a fps) = fps_const (of_nat n) * (1 + X) ^ (n - 1)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3998 | by (simp add: fps_deriv_power) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 3999 | also have "(1 + X :: 'a fps) $ 0 \<noteq> 0" by simp | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4000 | hence "(1 + X :: 'a fps) \<noteq> 0" by (intro notI) (simp only: , simp) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4001 | with False have "(1 + X :: 'a fps) ^ (n - 1) = (1 + X) ^ n / (1 + X)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4002 | by (cases n) (simp_all ) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4003 | also have "fps_const (of_nat n :: 'a) * ((1 + X) ^ n / (1 + X)) = | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4004 | fps_const (of_nat n) * (1 + X) ^ n / (1 + X)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4005 | by (simp add: unit_div_mult_swap) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4006 | finally show ?thesis | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4007 | by (subst sym, subst fps_binomial_ODE_unique' [symmetric]) (simp_all add: fps_power_nth) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4008 | qed | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4009 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4010 | lemma fps_binomial_0 [simp]: "fps_binomial 0 = 1" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4011 | using fps_binomial_of_nat[of 0] by simp | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4012 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4013 | lemma fps_binomial_power: "fps_binomial a ^ n = fps_binomial (of_nat n * a)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4014 | by (induction n) (simp_all add: fps_binomial_add_mult ring_distribs) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4015 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4016 | lemma fps_binomial_1: "fps_binomial 1 = 1 + X" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4017 | using fps_binomial_of_nat[of 1] by simp | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4018 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4019 | lemma fps_binomial_minus_of_nat: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4020 | "fps_binomial (- of_nat n) = inverse ((1 + X :: 'a :: field_char_0 fps) ^ n)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4021 | by (rule sym, rule fps_inverse_unique) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4022 | (simp add: fps_binomial_of_nat [symmetric] fps_binomial_add_mult [symmetric]) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4023 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4024 | lemma one_minus_const_X_power: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4025 | "c \<noteq> 0 \<Longrightarrow> (1 - fps_const c * X) ^ n = | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4026 | fps_compose (fps_binomial (of_nat n)) (-fps_const c * X)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4027 | by (subst fps_binomial_of_nat) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4028 | (simp add: fps_compose_power [symmetric] fps_compose_add_distrib fps_const_neg [symmetric] | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4029 | del: fps_const_neg) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4030 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4031 | lemma one_minus_X_const_neg_power: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4032 | "inverse ((1 - fps_const c * X) ^ n) = | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4033 | fps_compose (fps_binomial (-of_nat n)) (-fps_const c * X)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4034 | proof (cases "c = 0") | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4035 | case False | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4036 | thus ?thesis | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4037 | by (subst fps_binomial_minus_of_nat) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4038 | (simp add: fps_compose_power [symmetric] fps_inverse_compose fps_compose_add_distrib | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4039 | fps_const_neg [symmetric] del: fps_const_neg) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4040 | qed simp | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4041 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4042 | lemma X_plus_const_power: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4043 | "c \<noteq> 0 \<Longrightarrow> (X + fps_const c) ^ n = | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4044 | fps_const (c^n) * fps_compose (fps_binomial (of_nat n)) (fps_const (inverse c) * X)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4045 | by (subst fps_binomial_of_nat) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4046 | (simp add: fps_compose_power [symmetric] fps_binomial_of_nat fps_compose_add_distrib | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4047 | fps_const_power [symmetric] power_mult_distrib [symmetric] | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4048 | algebra_simps inverse_mult_eq_1' del: fps_const_power) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4049 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4050 | lemma X_plus_const_neg_power: | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4051 | "c \<noteq> 0 \<Longrightarrow> inverse ((X + fps_const c) ^ n) = | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4052 | fps_const (inverse c^n) * fps_compose (fps_binomial (-of_nat n)) (fps_const (inverse c) * X)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4053 | by (subst fps_binomial_minus_of_nat) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4054 | (simp add: fps_compose_power [symmetric] fps_binomial_of_nat fps_compose_add_distrib | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4055 | fps_const_power [symmetric] power_mult_distrib [symmetric] fps_inverse_compose | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4056 | algebra_simps fps_const_inverse [symmetric] fps_inverse_mult [symmetric] | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4057 | fps_inverse_power [symmetric] inverse_mult_eq_1' | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4058 | del: fps_const_power) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4059 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4060 | |
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4061 | lemma one_minus_const_X_neg_power': | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4062 | "n > 0 \<Longrightarrow> inverse ((1 - fps_const (c :: 'a :: field_char_0) * X) ^ n) = | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4063 | Abs_fps (\<lambda>k. of_nat ((n + k - 1) choose k) * c^k)" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4064 | apply (rule fps_ext) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4065 | apply (subst one_minus_X_const_neg_power, subst fps_const_neg, subst fps_compose_linear) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4066 | apply (simp add: power_mult_distrib [symmetric] mult.assoc [symmetric] | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4067 | gbinomial_minus binomial_gbinomial of_nat_diff) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4068 | done | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4069 | |
| 60558 | 4070 | text \<open>Vandermonde's Identity as a consequence.\<close> | 
| 53196 | 4071 | lemma gbinomial_Vandermonde: | 
| 64267 | 4072 |   "sum (\<lambda>k. (a gchoose k) * (b gchoose (n - k))) {0..n} = (a + b) gchoose n"
 | 
| 53196 | 4073 | proof - | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4074 | let ?ba = "fps_binomial a" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4075 | let ?bb = "fps_binomial b" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4076 | let ?bab = "fps_binomial (a + b)" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4077 | from fps_binomial_add_mult[of a b] have "?bab $ n = (?ba * ?bb)$n" by simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4078 | then show ?thesis by (simp add: fps_mult_nth) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4079 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4080 | |
| 53196 | 4081 | lemma binomial_Vandermonde: | 
| 64267 | 4082 |   "sum (\<lambda>k. (a choose k) * (b choose (n - k))) {0..n} = (a + b) choose n"
 | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4083 | using gbinomial_Vandermonde[of "(of_nat a)" "of_nat b" n] | 
| 61649 
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
 paulson <lp15@cam.ac.uk> parents: 
61610diff
changeset | 4084 | by (simp only: binomial_gbinomial[symmetric] of_nat_mult[symmetric] | 
| 64267 | 4085 | of_nat_sum[symmetric] of_nat_add[symmetric] of_nat_eq_iff) | 
| 4086 | ||
| 4087 | lemma binomial_Vandermonde_same: "sum (\<lambda>k. (n choose k)\<^sup>2) {0..n} = (2 * n) choose n"
 | |
| 60501 | 4088 | using binomial_Vandermonde[of n n n, symmetric] | 
| 53195 | 4089 | unfolding mult_2 | 
| 4090 | apply (simp add: power2_eq_square) | |
| 64267 | 4091 | apply (rule sum.cong) | 
| 53195 | 4092 | apply (auto intro: binomial_symmetric) | 
| 4093 | done | |
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4094 | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4095 | lemma Vandermonde_pochhammer_lemma: | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4096 | fixes a :: "'a::field_char_0" | 
| 60504 | 4097 |   assumes b: "\<forall>j\<in>{0 ..<n}. b \<noteq> of_nat j"
 | 
| 64267 | 4098 | shows "sum (\<lambda>k. (pochhammer (- a) k * pochhammer (- (of_nat n)) k) / | 
| 53196 | 4099 |       (of_nat (fact k) * pochhammer (b - of_nat n + 1) k)) {0..n} =
 | 
| 54452 | 4100 | pochhammer (- (a + b)) n / pochhammer (- b) n" | 
| 53196 | 4101 | (is "?l = ?r") | 
| 4102 | proof - | |
| 54452 | 4103 | let ?m1 = "\<lambda>m. (- 1 :: 'a) ^ m" | 
| 4104 | let ?f = "\<lambda>m. of_nat (fact m)" | |
| 4105 | let ?p = "\<lambda>(x::'a). pochhammer (- x)" | |
| 60501 | 4106 | from b have bn0: "?p b n \<noteq> 0" | 
| 4107 | unfolding pochhammer_eq_0_iff by simp | |
| 60558 | 4108 | have th00: | 
| 4109 | "b gchoose (n - k) = | |
| 4110 | (?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k)" | |
| 4111 | (is ?gchoose) | |
| 4112 | "pochhammer (1 + b - of_nat n) k \<noteq> 0" | |
| 4113 | (is ?pochhammer) | |
| 4114 |     if kn: "k \<in> {0..n}" for k
 | |
| 4115 | proof - | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 4116 | from kn have "k \<le> n" by simp | 
| 60501 | 4117 | have nz: "pochhammer (1 + b - of_nat n) n \<noteq> 0" | 
| 4118 | proof | |
| 4119 | assume "pochhammer (1 + b - of_nat n) n = 0" | |
| 4120 | then have c: "pochhammer (b - of_nat n + 1) n = 0" | |
| 4121 | by (simp add: algebra_simps) | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4122 | then obtain j where j: "j < n" "b - of_nat n + 1 = - of_nat j" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4123 | unfolding pochhammer_eq_0_iff by blast | 
| 52891 | 4124 | from j have "b = of_nat n - of_nat j - of_nat 1" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4125 | by (simp add: algebra_simps) | 
| 52891 | 4126 | then have "b = of_nat (n - j - 1)" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4127 | using j kn by (simp add: of_nat_diff) | 
| 60501 | 4128 | with b show False using j by auto | 
| 4129 | qed | |
| 52891 | 4130 | |
| 4131 | from nz kn [simplified] have nz': "pochhammer (1 + b - of_nat n) k \<noteq> 0" | |
| 35175 | 4132 | by (rule pochhammer_neq_0_mono) | 
| 60504 | 4133 | |
| 60567 | 4134 | consider "k = 0 \<or> n = 0" | "k \<noteq> 0" "n \<noteq> 0" | 
| 4135 | by blast | |
| 60504 | 4136 | then have "b gchoose (n - k) = | 
| 4137 | (?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k)" | |
| 4138 | proof cases | |
| 4139 | case 1 | |
| 4140 | then show ?thesis | |
| 4141 | using kn by (cases "k = 0") (simp_all add: gbinomial_pochhammer) | |
| 4142 | next | |
| 60567 | 4143 | case neq: 2 | 
| 60501 | 4144 | then obtain m where m: "n = Suc m" | 
| 4145 | by (cases n) auto | |
| 60567 | 4146 | from neq(1) obtain h where h: "k = Suc h" | 
| 60501 | 4147 | by (cases k) auto | 
| 60504 | 4148 | show ?thesis | 
| 60501 | 4149 | proof (cases "k = n") | 
| 4150 | case True | |
| 4151 | then show ?thesis | |
| 59862 | 4152 | using pochhammer_minus'[where k=k and b=b] | 
| 4153 | apply (simp add: pochhammer_same) | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4154 | using bn0 | 
| 53195 | 4155 | apply (simp add: field_simps power_add[symmetric]) | 
| 4156 | done | |
| 60501 | 4157 | next | 
| 4158 | case False | |
| 4159 | with kn have kn': "k < n" | |
| 4160 | by simp | |
| 64272 | 4161 |         have m1nk: "?m1 n = prod (\<lambda>i. - 1) {..m}" "?m1 k = prod (\<lambda>i. - 1) {0..h}"
 | 
| 4162 | by (simp_all add: prod_constant m h) | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4163 | have bnz0: "pochhammer (b - of_nat n + 1) k \<noteq> 0" | 
| 52891 | 4164 | using bn0 kn | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4165 | unfolding pochhammer_eq_0_iff | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4166 | apply auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4167 | apply (erule_tac x= "n - ka - 1" in allE) | 
| 53196 | 4168 | apply (auto simp add: algebra_simps of_nat_diff) | 
| 4169 | done | |
| 64272 | 4170 |         have eq1: "prod (\<lambda>k. (1::'a) + of_nat m - of_nat k) {..h} =
 | 
| 4171 |           prod of_nat {Suc (m - h) .. Suc m}"
 | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4172 | using kn' h m | 
| 64272 | 4173 | by (intro prod.reindex_bij_witness[where i="\<lambda>k. Suc m - k" and j="\<lambda>k. Suc m - k"]) | 
| 57129 
7edb7550663e
introduce more powerful reindexing rules for big operators
 hoelzl parents: 
56480diff
changeset | 4174 | (auto simp: of_nat_diff) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4175 | have th1: "(?m1 k * ?p (of_nat n) k) / ?f n = 1 / of_nat(fact (n - k))" | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 4176 | apply (simp add: pochhammer_minus field_simps) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 4177 | using \<open>k \<le> n\<close> apply (simp add: fact_split [of k n]) | 
| 64272 | 4178 | apply (simp add: pochhammer_prod) | 
| 4179 | using prod.atLeast_lessThan_shift_bounds [where ?'a = 'a, of "\<lambda>i. 1 + of_nat i" 0 "n - k" k] | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 4180 | apply (auto simp add: of_nat_diff field_simps) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4181 | done | 
| 64272 | 4182 |         have th20: "?m1 n * ?p b n = prod (\<lambda>i. b - of_nat i) {0..m}"
 | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 4183 | apply (simp add: pochhammer_minus field_simps m) | 
| 64272 | 4184 | apply (auto simp add: pochhammer_prod_rev of_nat_diff prod.atLeast_Suc_atMost_Suc_shift) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4185 | done | 
| 64272 | 4186 |         have th21:"pochhammer (b - of_nat n + 1) k = prod (\<lambda>i. b - of_nat i) {n - k .. n - 1}"
 | 
| 4187 | using kn apply (simp add: pochhammer_prod_rev m h prod.atLeast_Suc_atMost_Suc_shift) | |
| 4188 | using prod.atLeast_atMost_shift_0 [of "m - h" m, where ?'a = 'a] | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 4189 | apply (auto simp add: of_nat_diff field_simps) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 4190 | done | 
| 53196 | 4191 | have "?m1 n * ?p b n = | 
| 64272 | 4192 |           prod (\<lambda>i. b - of_nat i) {0.. n - k - 1} * pochhammer (b - of_nat n + 1) k"
 | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 4193 | using kn' m h unfolding th20 th21 apply simp | 
| 64272 | 4194 | apply (subst prod.union_disjoint [symmetric]) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4195 | apply auto | 
| 64272 | 4196 | apply (rule prod.cong) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4197 | apply auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4198 | done | 
| 53196 | 4199 | then have th2: "(?m1 n * ?p b n)/pochhammer (b - of_nat n + 1) k = | 
| 64272 | 4200 |           prod (\<lambda>i. b - of_nat i) {0.. n - k - 1}"
 | 
| 36350 | 4201 | using nz' by (simp add: field_simps) | 
| 53196 | 4202 | have "(?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k) = | 
| 4203 | ((?m1 k * ?p (of_nat n) k) / ?f n) * ((?m1 n * ?p b n)/pochhammer (b - of_nat n + 1) k)" | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4204 | using bnz0 | 
| 36350 | 4205 | by (simp add: field_simps) | 
| 52891 | 4206 | also have "\<dots> = b gchoose (n - k)" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 4207 | unfolding th1 th2 | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 4208 | using kn' m h | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 4209 | apply (simp add: field_simps gbinomial_mult_fact) | 
| 64272 | 4210 | apply (rule prod.cong) | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 4211 | apply auto | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 4212 | done | 
| 60501 | 4213 | finally show ?thesis by simp | 
| 4214 | qed | |
| 60504 | 4215 | qed | 
| 60558 | 4216 | then show ?gchoose and ?pochhammer | 
| 53195 | 4217 | apply (cases "n = 0") | 
| 52891 | 4218 | using nz' | 
| 53195 | 4219 | apply auto | 
| 4220 | done | |
| 60558 | 4221 | qed | 
| 60504 | 4222 | have "?r = ((a + b) gchoose n) * (of_nat (fact n) / (?m1 n * pochhammer (- b) n))" | 
| 52891 | 4223 | unfolding gbinomial_pochhammer | 
| 36350 | 4224 | using bn0 by (auto simp add: field_simps) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4225 | also have "\<dots> = ?l" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4226 | unfolding gbinomial_Vandermonde[symmetric] | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4227 | apply (simp add: th00) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4228 | unfolding gbinomial_pochhammer | 
| 53196 | 4229 | using bn0 | 
| 64267 | 4230 | apply (simp add: sum_distrib_right sum_distrib_left field_simps) | 
| 53196 | 4231 | done | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4232 | finally show ?thesis by simp | 
| 52891 | 4233 | qed | 
| 4234 | ||
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4235 | lemma Vandermonde_pochhammer: | 
| 53195 | 4236 | fixes a :: "'a::field_char_0" | 
| 54452 | 4237 |   assumes c: "\<forall>i \<in> {0..< n}. c \<noteq> - of_nat i"
 | 
| 64267 | 4238 | shows "sum (\<lambda>k. (pochhammer a k * pochhammer (- (of_nat n)) k) / | 
| 53195 | 4239 |     (of_nat (fact k) * pochhammer c k)) {0..n} = pochhammer (c - a) n / pochhammer c n"
 | 
| 4240 | proof - | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4241 | let ?a = "- a" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4242 | let ?b = "c + of_nat n - 1" | 
| 60558 | 4243 |   have h: "\<forall> j \<in>{0..< n}. ?b \<noteq> of_nat j"
 | 
| 4244 | using c | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4245 | apply (auto simp add: algebra_simps of_nat_diff) | 
| 60501 | 4246 | apply (erule_tac x = "n - j - 1" in ballE) | 
| 53195 | 4247 | apply (auto simp add: of_nat_diff algebra_simps) | 
| 4248 | done | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4249 | have th0: "pochhammer (- (?a + ?b)) n = (- 1)^n * pochhammer (c - a) n" | 
| 59862 | 4250 | unfolding pochhammer_minus | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4251 | by (simp add: algebra_simps) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4252 | have th1: "pochhammer (- ?b) n = (- 1)^n * pochhammer c n" | 
| 59862 | 4253 | unfolding pochhammer_minus | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4254 | by simp | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4255 | have nz: "pochhammer c n \<noteq> 0" using c | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4256 | by (simp add: pochhammer_eq_0_iff) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4257 | from Vandermonde_pochhammer_lemma[where a = "?a" and b="?b" and n=n, OF h, unfolded th0 th1] | 
| 60501 | 4258 | show ?thesis | 
| 64267 | 4259 | using nz by (simp add: field_simps sum_distrib_left) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4260 | qed | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4261 | |
| 53195 | 4262 | |
| 60501 | 4263 | subsubsection \<open>Formal trigonometric functions\<close> | 
| 29687 | 4264 | |
| 31273 | 4265 | definition "fps_sin (c::'a::field_char_0) = | 
| 29687 | 4266 | Abs_fps (\<lambda>n. if even n then 0 else (- 1) ^((n - 1) div 2) * c^n /(of_nat (fact n)))" | 
| 4267 | ||
| 31273 | 4268 | definition "fps_cos (c::'a::field_char_0) = | 
| 4269 | Abs_fps (\<lambda>n. if even n then (- 1) ^ (n div 2) * c^n / (of_nat (fact n)) else 0)" | |
| 29687 | 4270 | |
| 30488 | 4271 | lemma fps_sin_deriv: | 
| 29687 | 4272 | "fps_deriv (fps_sin c) = fps_const c * fps_cos c" | 
| 4273 | (is "?lhs = ?rhs") | |
| 31273 | 4274 | proof (rule fps_ext) | 
| 53195 | 4275 | fix n :: nat | 
| 60501 | 4276 | show "?lhs $ n = ?rhs $ n" | 
| 4277 | proof (cases "even n") | |
| 4278 | case True | |
| 52902 | 4279 | have "?lhs$n = of_nat (n+1) * (fps_sin c $ (n+1))" by simp | 
| 4280 | also have "\<dots> = of_nat (n+1) * ((- 1)^(n div 2) * c^Suc n / of_nat (fact (Suc n)))" | |
| 60501 | 4281 | using True by (simp add: fps_sin_def) | 
| 52902 | 4282 | also have "\<dots> = (- 1)^(n div 2) * c^Suc n * (of_nat (n+1) / (of_nat (Suc n) * of_nat (fact n)))" | 
| 4283 | unfolding fact_Suc of_nat_mult | |
| 4284 | by (simp add: field_simps del: of_nat_add of_nat_Suc) | |
| 4285 | also have "\<dots> = (- 1)^(n div 2) *c^Suc n / of_nat (fact n)" | |
| 4286 | by (simp add: field_simps del: of_nat_add of_nat_Suc) | |
| 60501 | 4287 | finally show ?thesis | 
| 4288 | using True by (simp add: fps_cos_def field_simps) | |
| 4289 | next | |
| 4290 | case False | |
| 4291 | then show ?thesis | |
| 4292 | by (simp_all add: fps_deriv_def fps_sin_def fps_cos_def) | |
| 4293 | qed | |
| 29687 | 4294 | qed | 
| 4295 | ||
| 52902 | 4296 | lemma fps_cos_deriv: "fps_deriv (fps_cos c) = fps_const (- c)* (fps_sin c)" | 
| 29687 | 4297 | (is "?lhs = ?rhs") | 
| 31273 | 4298 | proof (rule fps_ext) | 
| 60501 | 4299 | have th0: "- ((- 1::'a) ^ n) = (- 1)^Suc n" for n | 
| 4300 | by simp | |
| 4301 | show "?lhs $ n = ?rhs $ n" for n | |
| 4302 | proof (cases "even n") | |
| 4303 | case False | |
| 4304 | then have n0: "n \<noteq> 0" by presburger | |
| 4305 | from False have th1: "Suc ((n - 1) div 2) = Suc n div 2" | |
| 4306 | by (cases n) simp_all | |
| 52902 | 4307 | have "?lhs$n = of_nat (n+1) * (fps_cos c $ (n+1))" by simp | 
| 4308 | also have "\<dots> = of_nat (n+1) * ((- 1)^((n + 1) div 2) * c^Suc n / of_nat (fact (Suc n)))" | |
| 60501 | 4309 | using False by (simp add: fps_cos_def) | 
| 52902 | 4310 | also have "\<dots> = (- 1)^((n + 1) div 2)*c^Suc n * (of_nat (n+1) / (of_nat (Suc n) * of_nat (fact n)))" | 
| 4311 | unfolding fact_Suc of_nat_mult | |
| 4312 | by (simp add: field_simps del: of_nat_add of_nat_Suc) | |
| 4313 | also have "\<dots> = (- 1)^((n + 1) div 2) * c^Suc n / of_nat (fact n)" | |
| 4314 | by (simp add: field_simps del: of_nat_add of_nat_Suc) | |
| 4315 | also have "\<dots> = (- ((- 1)^((n - 1) div 2))) * c^Suc n / of_nat (fact n)" | |
| 60501 | 4316 | unfolding th0 unfolding th1 by simp | 
| 4317 | finally show ?thesis | |
| 4318 | using False by (simp add: fps_sin_def field_simps) | |
| 4319 | next | |
| 4320 | case True | |
| 4321 | then show ?thesis | |
| 4322 | by (simp_all add: fps_deriv_def fps_sin_def fps_cos_def) | |
| 4323 | qed | |
| 29687 | 4324 | qed | 
| 4325 | ||
| 60501 | 4326 | lemma fps_sin_cos_sum_of_squares: "(fps_cos c)\<^sup>2 + (fps_sin c)\<^sup>2 = 1" | 
| 4327 | (is "?lhs = _") | |
| 53077 | 4328 | proof - | 
| 29687 | 4329 | have "fps_deriv ?lhs = 0" | 
| 52902 | 4330 | apply (simp add: fps_deriv_power fps_sin_deriv fps_cos_deriv) | 
| 4331 | apply (simp add: field_simps fps_const_neg[symmetric] del: fps_const_neg) | |
| 4332 | done | |
| 29687 | 4333 | then have "?lhs = fps_const (?lhs $ 0)" | 
| 4334 | unfolding fps_deriv_eq_0_iff . | |
| 4335 | also have "\<dots> = 1" | |
| 30960 | 4336 | by (auto simp add: fps_eq_iff numeral_2_eq_2 fps_mult_nth fps_cos_def fps_sin_def) | 
| 29687 | 4337 | finally show ?thesis . | 
| 4338 | qed | |
| 4339 | ||
| 31274 | 4340 | lemma fps_sin_nth_0 [simp]: "fps_sin c $ 0 = 0" | 
| 53195 | 4341 | unfolding fps_sin_def by simp | 
| 31274 | 4342 | |
| 4343 | lemma fps_sin_nth_1 [simp]: "fps_sin c $ 1 = c" | |
| 53195 | 4344 | unfolding fps_sin_def by simp | 
| 31274 | 4345 | |
| 4346 | lemma fps_sin_nth_add_2: | |
| 60501 | 4347 | "fps_sin c $ (n + 2) = - (c * c * fps_sin c $ n / (of_nat (n + 1) * of_nat (n + 2)))" | 
| 53195 | 4348 | unfolding fps_sin_def | 
| 60501 | 4349 | apply (cases n) | 
| 4350 | apply simp | |
| 60162 | 4351 | apply (simp add: nonzero_divide_eq_eq nonzero_eq_divide_eq del: of_nat_Suc fact_Suc) | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 4352 | apply simp | 
| 53195 | 4353 | done | 
| 31274 | 4354 | |
| 4355 | lemma fps_cos_nth_0 [simp]: "fps_cos c $ 0 = 1" | |
| 53195 | 4356 | unfolding fps_cos_def by simp | 
| 31274 | 4357 | |
| 4358 | lemma fps_cos_nth_1 [simp]: "fps_cos c $ 1 = 0" | |
| 53195 | 4359 | unfolding fps_cos_def by simp | 
| 31274 | 4360 | |
| 4361 | lemma fps_cos_nth_add_2: | |
| 60501 | 4362 | "fps_cos c $ (n + 2) = - (c * c * fps_cos c $ n / (of_nat (n + 1) * of_nat (n + 2)))" | 
| 52902 | 4363 | unfolding fps_cos_def | 
| 60162 | 4364 | apply (simp add: nonzero_divide_eq_eq nonzero_eq_divide_eq del: of_nat_Suc fact_Suc) | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 4365 | apply simp | 
| 52902 | 4366 | done | 
| 4367 | ||
| 4368 | lemma nat_induct2: "P 0 \<Longrightarrow> P 1 \<Longrightarrow> (\<And>n. P n \<Longrightarrow> P (n + 2)) \<Longrightarrow> P (n::nat)" | |
| 4369 | unfolding One_nat_def numeral_2_eq_2 | |
| 4370 | apply (induct n rule: nat_less_induct) | |
| 53196 | 4371 | apply (case_tac n) | 
| 4372 | apply simp | |
| 4373 | apply (rename_tac m) | |
| 4374 | apply (case_tac m) | |
| 4375 | apply simp | |
| 4376 | apply (rename_tac k) | |
| 4377 | apply (case_tac k) | |
| 4378 | apply simp_all | |
| 52902 | 4379 | done | 
| 31274 | 4380 | |
| 4381 | lemma nat_add_1_add_1: "(n::nat) + 1 + 1 = n + 2" | |
| 52902 | 4382 | by simp | 
| 31274 | 4383 | |
| 4384 | lemma eq_fps_sin: | |
| 52902 | 4385 | assumes 0: "a $ 0 = 0" | 
| 4386 | and 1: "a $ 1 = c" | |
| 4387 | and 2: "fps_deriv (fps_deriv a) = - (fps_const c * fps_const c * a)" | |
| 31274 | 4388 | shows "a = fps_sin c" | 
| 52902 | 4389 | apply (rule fps_ext) | 
| 4390 | apply (induct_tac n rule: nat_induct2) | |
| 4391 | apply (simp add: 0) | |
| 4392 | apply (simp add: 1 del: One_nat_def) | |
| 4393 | apply (rename_tac m, cut_tac f="\<lambda>a. a $ m" in arg_cong [OF 2]) | |
| 4394 | apply (simp add: nat_add_1_add_1 fps_sin_nth_add_2 | |
| 4395 | del: One_nat_def of_nat_Suc of_nat_add add_2_eq_Suc') | |
| 4396 | apply (subst minus_divide_left) | |
| 60162 | 4397 | apply (subst nonzero_eq_divide_eq) | 
| 52902 | 4398 | apply (simp del: of_nat_add of_nat_Suc) | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 4399 | apply (simp only: ac_simps) | 
| 52902 | 4400 | done | 
| 31274 | 4401 | |
| 4402 | lemma eq_fps_cos: | |
| 52902 | 4403 | assumes 0: "a $ 0 = 1" | 
| 4404 | and 1: "a $ 1 = 0" | |
| 4405 | and 2: "fps_deriv (fps_deriv a) = - (fps_const c * fps_const c * a)" | |
| 31274 | 4406 | shows "a = fps_cos c" | 
| 52902 | 4407 | apply (rule fps_ext) | 
| 4408 | apply (induct_tac n rule: nat_induct2) | |
| 4409 | apply (simp add: 0) | |
| 4410 | apply (simp add: 1 del: One_nat_def) | |
| 4411 | apply (rename_tac m, cut_tac f="\<lambda>a. a $ m" in arg_cong [OF 2]) | |
| 4412 | apply (simp add: nat_add_1_add_1 fps_cos_nth_add_2 | |
| 4413 | del: One_nat_def of_nat_Suc of_nat_add add_2_eq_Suc') | |
| 4414 | apply (subst minus_divide_left) | |
| 60162 | 4415 | apply (subst nonzero_eq_divide_eq) | 
| 52902 | 4416 | apply (simp del: of_nat_add of_nat_Suc) | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 4417 | apply (simp only: ac_simps) | 
| 52902 | 4418 | done | 
| 31274 | 4419 | |
| 4420 | lemma mult_nth_0 [simp]: "(a * b) $ 0 = a $ 0 * b $ 0" | |
| 52902 | 4421 | by (simp add: fps_mult_nth) | 
| 31274 | 4422 | |
| 4423 | lemma mult_nth_1 [simp]: "(a * b) $ 1 = a $ 0 * b $ 1 + a $ 1 * b $ 0" | |
| 52902 | 4424 | by (simp add: fps_mult_nth) | 
| 4425 | ||
| 4426 | lemma fps_sin_add: "fps_sin (a + b) = fps_sin a * fps_cos b + fps_cos a * fps_sin b" | |
| 4427 | apply (rule eq_fps_sin [symmetric], simp, simp del: One_nat_def) | |
| 4428 | apply (simp del: fps_const_neg fps_const_add fps_const_mult | |
| 4429 | add: fps_const_add [symmetric] fps_const_neg [symmetric] | |
| 4430 | fps_sin_deriv fps_cos_deriv algebra_simps) | |
| 4431 | done | |
| 4432 | ||
| 4433 | lemma fps_cos_add: "fps_cos (a + b) = fps_cos a * fps_cos b - fps_sin a * fps_sin b" | |
| 4434 | apply (rule eq_fps_cos [symmetric], simp, simp del: One_nat_def) | |
| 4435 | apply (simp del: fps_const_neg fps_const_add fps_const_mult | |
| 4436 | add: fps_const_add [symmetric] fps_const_neg [symmetric] | |
| 4437 | fps_sin_deriv fps_cos_deriv algebra_simps) | |
| 4438 | done | |
| 31274 | 4439 | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 4440 | lemma fps_sin_even: "fps_sin (- c) = - fps_sin c" | 
| 56479 
91958d4b30f7
revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
 hoelzl parents: 
56410diff
changeset | 4441 | by (auto simp add: fps_eq_iff fps_sin_def) | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 4442 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 4443 | lemma fps_cos_odd: "fps_cos (- c) = fps_cos c" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 4444 | by (auto simp add: fps_eq_iff fps_cos_def) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 4445 | |
| 29687 | 4446 | definition "fps_tan c = fps_sin c / fps_cos c" | 
| 4447 | ||
| 53077 | 4448 | lemma fps_tan_deriv: "fps_deriv (fps_tan c) = fps_const c / (fps_cos c)\<^sup>2" | 
| 52902 | 4449 | proof - | 
| 29687 | 4450 | have th0: "fps_cos c $ 0 \<noteq> 0" by (simp add: fps_cos_def) | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4451 | from this have "fps_cos c \<noteq> 0" by (intro notI) simp | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 4452 | hence "fps_deriv (fps_tan c) = | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4453 | fps_const c * (fps_cos c^2 + fps_sin c^2) / (fps_cos c^2)" | 
| 62102 
877463945ce9
fix code generation for uniformity: uniformity is a non-computable pure data.
 hoelzl parents: 
62101diff
changeset | 4454 | by (simp add: fps_tan_def fps_divide_deriv power2_eq_square algebra_simps | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4455 | fps_sin_deriv fps_cos_deriv fps_const_neg[symmetric] div_mult_swap | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4456 | del: fps_const_neg) | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4457 | also note fps_sin_cos_sum_of_squares | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4458 | finally show ?thesis by simp | 
| 29687 | 4459 | qed | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 4460 | |
| 60558 | 4461 | text \<open>Connection to E c over the complex numbers --- Euler and de Moivre.\<close> | 
| 60501 | 4462 | |
| 63589 | 4463 | lemma Eii_sin_cos: "E (\<i> * c) = fps_cos c + fps_const \<i> * fps_sin c" | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4464 | (is "?l = ?r") | 
| 52902 | 4465 | proof - | 
| 60501 | 4466 | have "?l $ n = ?r $ n" for n | 
| 4467 | proof (cases "even n") | |
| 4468 | case True | |
| 4469 | then obtain m where m: "n = 2 * m" .. | |
| 4470 | show ?thesis | |
| 4471 | by (simp add: m fps_sin_def fps_cos_def power_mult_distrib power_mult power_minus [of "c ^ 2"]) | |
| 4472 | next | |
| 4473 | case False | |
| 4474 | then obtain m where m: "n = 2 * m + 1" .. | |
| 4475 | show ?thesis | |
| 4476 | by (simp add: m fps_sin_def fps_cos_def power_mult_distrib | |
| 4477 | power_mult power_minus [of "c ^ 2"]) | |
| 4478 | qed | |
| 4479 | then show ?thesis | |
| 4480 | by (simp add: fps_eq_iff) | |
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4481 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4482 | |
| 63589 | 4483 | lemma E_minus_ii_sin_cos: "E (- (\<i> * c)) = fps_cos c - fps_const \<i> * fps_sin c" | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4484 | unfolding minus_mult_right Eii_sin_cos by (simp add: fps_sin_even fps_cos_odd) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4485 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4486 | lemma fps_const_minus: "fps_const (c::'a::group_add) - fps_const d = fps_const (c - d)" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4487 | by (fact fps_const_sub) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4488 | |
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4489 | lemma fps_of_int: "fps_const (of_int c) = of_int c" | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4490 | by (induction c) (simp_all add: fps_const_minus [symmetric] fps_of_nat fps_const_neg [symmetric] | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4491 | del: fps_const_minus fps_const_neg) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63040diff
changeset | 4492 | |
| 54681 | 4493 | lemma fps_numeral_fps_const: "numeral i = fps_const (numeral i :: 'a::comm_ring_1)" | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 4494 | by (fact numeral_fps_const) (* FIXME: duplicate *) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4495 | |
| 63589 | 4496 | lemma fps_cos_Eii: "fps_cos c = (E (\<i> * c) + E (- \<i> * c)) / fps_const 2" | 
| 52902 | 4497 | proof - | 
| 52891 | 4498 | have th: "fps_cos c + fps_cos c = fps_cos c * fps_const 2" | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 4499 | by (simp add: numeral_fps_const) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4500 | show ?thesis | 
| 60501 | 4501 | unfolding Eii_sin_cos minus_mult_commute | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4502 | by (simp add: fps_sin_even fps_cos_odd numeral_fps_const fps_divide_unit fps_const_inverse th) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4503 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4504 | |
| 63589 | 4505 | lemma fps_sin_Eii: "fps_sin c = (E (\<i> * c) - E (- \<i> * c)) / fps_const (2*\<i>)" | 
| 52902 | 4506 | proof - | 
| 63589 | 4507 | have th: "fps_const \<i> * fps_sin c + fps_const \<i> * fps_sin c = fps_sin c * fps_const (2 * \<i>)" | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 4508 | by (simp add: fps_eq_iff numeral_fps_const) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4509 | show ?thesis | 
| 52902 | 4510 | unfolding Eii_sin_cos minus_mult_commute | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4511 | by (simp add: fps_sin_even fps_cos_odd fps_divide_unit fps_const_inverse th) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4512 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4513 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4514 | lemma fps_tan_Eii: | 
| 63589 | 4515 | "fps_tan c = (E (\<i> * c) - E (- \<i> * c)) / (fps_const \<i> * (E (\<i> * c) + E (- \<i> * c)))" | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4516 | unfolding fps_tan_def fps_sin_Eii fps_cos_Eii mult_minus_left E_neg | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4517 | apply (simp add: fps_divide_unit fps_inverse_mult fps_const_mult[symmetric] fps_const_inverse del: fps_const_mult) | 
| 52902 | 4518 | apply simp | 
| 4519 | done | |
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4520 | |
| 60501 | 4521 | lemma fps_demoivre: | 
| 63589 | 4522 | "(fps_cos a + fps_const \<i> * fps_sin a)^n = | 
| 4523 | fps_cos (of_nat n * a) + fps_const \<i> * fps_sin (of_nat n * a)" | |
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4524 | unfolding Eii_sin_cos[symmetric] E_power_mult | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 4525 | by (simp add: ac_simps) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 4526 | |
| 52902 | 4527 | |
| 60500 | 4528 | subsection \<open>Hypergeometric series\<close> | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4529 | |
| 62422 | 4530 | (* TODO: Rename this *) | 
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
59862diff
changeset | 4531 | definition "F as bs (c::'a::{field_char_0,field}) =
 | 
| 54452 | 4532 | Abs_fps (\<lambda>n. (foldl (\<lambda>r a. r* pochhammer a n) 1 as * c^n) / | 
| 4533 | (foldl (\<lambda>r b. r * pochhammer b n) 1 bs * of_nat (fact n)))" | |
| 52902 | 4534 | |
| 4535 | lemma F_nth[simp]: "F as bs c $ n = | |
| 4536 | (foldl (\<lambda>r a. r* pochhammer a n) 1 as * c^n) / | |
| 4537 | (foldl (\<lambda>r b. r * pochhammer b n) 1 bs * of_nat (fact n))" | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4538 | by (simp add: F_def) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4539 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4540 | lemma foldl_mult_start: | 
| 54452 | 4541 | fixes v :: "'a::comm_ring_1" | 
| 4542 | shows "foldl (\<lambda>r x. r * f x) v as * x = foldl (\<lambda>r x. r * f x) (v * x) as " | |
| 48757 | 4543 | by (induct as arbitrary: x v) (auto simp add: algebra_simps) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4544 | |
| 53196 | 4545 | lemma foldr_mult_foldl: | 
| 54452 | 4546 | fixes v :: "'a::comm_ring_1" | 
| 4547 | shows "foldr (\<lambda>x r. r * f x) as v = foldl (\<lambda>r x. r * f x) v as" | |
| 48757 | 4548 | by (induct as arbitrary: v) (auto simp add: foldl_mult_start) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4549 | |
| 53196 | 4550 | lemma F_nth_alt: | 
| 4551 | "F as bs c $ n = foldr (\<lambda>a r. r * pochhammer a n) as (c ^ n) / | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4552 | foldr (\<lambda>b r. r * pochhammer b n) bs (of_nat (fact n))" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4553 | by (simp add: foldl_mult_start foldr_mult_foldl) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4554 | |
| 52891 | 4555 | lemma F_E[simp]: "F [] [] c = E c" | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4556 | by (simp add: fps_eq_iff) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4557 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4558 | lemma F_1_0[simp]: "F [1] [] c = 1/(1 - fps_const c * X)" | 
| 52902 | 4559 | proof - | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4560 | let ?a = "(Abs_fps (\<lambda>n. 1)) oo (fps_const c * X)" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4561 | have th0: "(fps_const c * X) $ 0 = 0" by simp | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4562 | show ?thesis unfolding gp[OF th0, symmetric] | 
| 53196 | 4563 | by (auto simp add: fps_eq_iff pochhammer_fact[symmetric] | 
| 64267 | 4564 | fps_compose_nth power_mult_distrib cond_value_iff sum.delta' cong del: if_weak_cong) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4565 | qed | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4566 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4567 | lemma F_B[simp]: "F [-a] [] (- 1) = fps_binomial a" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4568 | by (simp add: fps_eq_iff gbinomial_pochhammer algebra_simps) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4569 | |
| 60501 | 4570 | lemma F_0[simp]: "F as bs c $ 0 = 1" | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4571 | apply simp | 
| 54452 | 4572 | apply (subgoal_tac "\<forall>as. foldl (\<lambda>(r::'a) (a::'a). r) 1 as = 1") | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4573 | apply auto | 
| 48757 | 4574 | apply (induct_tac as) | 
| 4575 | apply auto | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4576 | done | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4577 | |
| 53196 | 4578 | lemma foldl_prod_prod: | 
| 54452 | 4579 | "foldl (\<lambda>(r::'b::comm_ring_1) (x::'a::comm_ring_1). r * f x) v as * foldl (\<lambda>r x. r * g x) w as = | 
| 4580 | foldl (\<lambda>r x. r * f x * g x) (v * w) as" | |
| 48757 | 4581 | by (induct as arbitrary: v w) (auto simp add: algebra_simps) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4582 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4583 | |
| 53196 | 4584 | lemma F_rec: | 
| 54452 | 4585 | "F as bs c $ Suc n = ((foldl (\<lambda>r a. r* (a + of_nat n)) c as) / | 
| 4586 | (foldl (\<lambda>r b. r * (b + of_nat n)) (of_nat (Suc n)) bs )) * F as bs c $ n" | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4587 | apply (simp del: of_nat_Suc of_nat_add fact_Suc) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4588 | apply (simp add: foldl_mult_start del: fact_Suc of_nat_Suc) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4589 | unfolding foldl_prod_prod[unfolded foldl_mult_start] pochhammer_Suc | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63367diff
changeset | 4590 | apply (simp add: algebra_simps) | 
| 52902 | 4591 | done | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4592 | |
| 54452 | 4593 | lemma XD_nth[simp]: "XD a $ n = (if n = 0 then 0 else of_nat n * a$n)" | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4594 | by (simp add: XD_def) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4595 | |
| 60501 | 4596 | lemma XD_0th[simp]: "XD a $ 0 = 0" | 
| 4597 | by simp | |
| 4598 | lemma XD_Suc[simp]:" XD a $ Suc n = of_nat (Suc n) * a $ Suc n" | |
| 4599 | by simp | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4600 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4601 | definition "XDp c a = XD a + fps_const c * a" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4602 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4603 | lemma XDp_nth[simp]: "XDp c a $ n = (c + of_nat n) * a$n" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4604 | by (simp add: XDp_def algebra_simps) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4605 | |
| 54681 | 4606 | lemma XDp_commute: "XDp b \<circ> XDp (c::'a::comm_ring_1) = XDp c \<circ> XDp b" | 
| 39302 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 nipkow parents: 
39198diff
changeset | 4607 | by (auto simp add: XDp_def fun_eq_iff fps_eq_iff algebra_simps) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4608 | |
| 52902 | 4609 | lemma XDp0 [simp]: "XDp 0 = XD" | 
| 39302 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 nipkow parents: 
39198diff
changeset | 4610 | by (simp add: fun_eq_iff fps_eq_iff) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4611 | |
| 52902 | 4612 | lemma XDp_fps_integral [simp]: "XDp 0 (fps_integral a c) = X * a" | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4613 | by (simp add: fps_eq_iff fps_integral_def) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4614 | |
| 52891 | 4615 | lemma F_minus_nat: | 
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
59862diff
changeset | 4616 |   "F [- of_nat n] [- of_nat (n + m)] (c::'a::{field_char_0,field}) $ k =
 | 
| 54452 | 4617 | (if k \<le> n then | 
| 52902 | 4618 | pochhammer (- of_nat n) k * c ^ k / (pochhammer (- of_nat (n + m)) k * of_nat (fact k)) | 
| 4619 | else 0)" | |
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
59862diff
changeset | 4620 |   "F [- of_nat m] [- of_nat (m + n)] (c::'a::{field_char_0,field}) $ k =
 | 
| 54452 | 4621 | (if k \<le> m then | 
| 52902 | 4622 | pochhammer (- of_nat m) k * c ^ k / (pochhammer (- of_nat (m + n)) k * of_nat (fact k)) | 
| 4623 | else 0)" | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4624 | by (auto simp add: pochhammer_eq_0_iff) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4625 | |
| 64267 | 4626 | lemma sum_eq_if: "sum f {(n::nat) .. m} = (if m < n then 0 else f n + sum f {n+1 .. m})"
 | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4627 | apply simp | 
| 64267 | 4628 | apply (subst sum.insert[symmetric]) | 
| 4629 | apply (auto simp add: not_less sum_head_Suc) | |
| 52902 | 4630 | done | 
| 4631 | ||
| 4632 | lemma pochhammer_rec_if: "pochhammer a n = (if n = 0 then 1 else a * pochhammer (a + 1) (n - 1))" | |
| 4633 | by (cases n) (simp_all add: pochhammer_rec) | |
| 4634 | ||
| 54681 | 4635 | lemma XDp_foldr_nth [simp]: "foldr (\<lambda>c r. XDp c \<circ> r) cs (\<lambda>c. XDp c a) c0 $ n = | 
| 54452 | 4636 | foldr (\<lambda>c r. (c + of_nat n) * r) cs (c0 + of_nat n) * a$n" | 
| 48757 | 4637 | by (induct cs arbitrary: c0) (auto simp add: algebra_simps) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4638 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4639 | lemma genric_XDp_foldr_nth: | 
| 54452 | 4640 | assumes f: "\<forall>n c a. f c a $ n = (of_nat n + k c) * a$n" | 
| 54681 | 4641 | shows "foldr (\<lambda>c r. f c \<circ> r) cs (\<lambda>c. g c a) c0 $ n = | 
| 54452 | 4642 | foldr (\<lambda>c r. (k c + of_nat n) * r) cs (g c0 a $ n)" | 
| 48757 | 4643 | by (induct cs arbitrary: c0) (auto simp add: algebra_simps f) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 4644 | |
| 51107 | 4645 | lemma dist_less_imp_nth_equal: | 
| 4646 | assumes "dist f g < inverse (2 ^ i)" | |
| 52902 | 4647 | and"j \<le> i" | 
| 51107 | 4648 | shows "f $ j = g $ j" | 
| 54263 
c4159fe6fa46
move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
 hoelzl parents: 
54230diff
changeset | 4649 | proof (rule ccontr) | 
| 
c4159fe6fa46
move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
 hoelzl parents: 
54230diff
changeset | 4650 | assume "f $ j \<noteq> g $ j" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4651 | hence "f \<noteq> g" by auto | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4652 | with assms have "i < subdegree (f - g)" | 
| 62390 | 4653 | by (simp add: if_split_asm dist_fps_def) | 
| 54263 
c4159fe6fa46
move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
 hoelzl parents: 
54230diff
changeset | 4654 | also have "\<dots> \<le> j" | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4655 | using \<open>f $ j \<noteq> g $ j\<close> by (intro subdegree_leI) simp_all | 
| 60500 | 4656 | finally show False using \<open>j \<le> i\<close> by simp | 
| 52902 | 4657 | qed | 
| 51107 | 4658 | |
| 4659 | lemma nth_equal_imp_dist_less: | |
| 4660 | assumes "\<And>j. j \<le> i \<Longrightarrow> f $ j = g $ j" | |
| 4661 | shows "dist f g < inverse (2 ^ i)" | |
| 52902 | 4662 | proof (cases "f = g") | 
| 60501 | 4663 | case True | 
| 4664 | then show ?thesis by simp | |
| 4665 | next | |
| 52902 | 4666 | case False | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4667 | with assms have "dist f g = inverse (2 ^ subdegree (f - g))" | 
| 62390 | 4668 | by (simp add: if_split_asm dist_fps_def) | 
| 51107 | 4669 | moreover | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4670 | from assms and False have "i < subdegree (f - g)" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4671 | by (intro subdegree_greaterI) simp_all | 
| 51107 | 4672 | ultimately show ?thesis by simp | 
| 60501 | 4673 | qed | 
| 52902 | 4674 | |
| 4675 | lemma dist_less_eq_nth_equal: "dist f g < inverse (2 ^ i) \<longleftrightarrow> (\<forall>j \<le> i. f $ j = g $ j)" | |
| 51107 | 4676 | using dist_less_imp_nth_equal nth_equal_imp_dist_less by blast | 
| 4677 | ||
| 4678 | instance fps :: (comm_ring_1) complete_space | |
| 4679 | proof | |
| 54681 | 4680 | fix X :: "nat \<Rightarrow> 'a fps" | 
| 51107 | 4681 | assume "Cauchy X" | 
| 60501 | 4682 | obtain M where M: "\<forall>i. \<forall>m \<ge> M i. \<forall>j \<le> i. X (M i) $ j = X m $ j" | 
| 4683 | proof - | |
| 4684 | have "\<exists>M. \<forall>m \<ge> M. \<forall>j\<le>i. X M $ j = X m $ j" for i | |
| 4685 | proof - | |
| 4686 | have "0 < inverse ((2::real)^i)" by simp | |
| 4687 | from metric_CauchyD[OF \<open>Cauchy X\<close> this] dist_less_imp_nth_equal | |
| 4688 | show ?thesis by blast | |
| 4689 | qed | |
| 4690 | then show ?thesis using that by metis | |
| 4691 | qed | |
| 4692 | ||
| 51107 | 4693 | show "convergent X" | 
| 4694 | proof (rule convergentI) | |
| 61969 | 4695 | show "X \<longlonglongrightarrow> Abs_fps (\<lambda>i. X (M i) $ i)" | 
| 51107 | 4696 | unfolding tendsto_iff | 
| 4697 | proof safe | |
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4698 | fix e::real assume e: "0 < e" | 
| 61969 | 4699 | have "(\<lambda>n. inverse (2 ^ n) :: real) \<longlonglongrightarrow> 0" by (rule LIMSEQ_inverse_realpow_zero) simp_all | 
| 61608 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4700 | from this and e have "eventually (\<lambda>i. inverse (2 ^ i) < e) sequentially" | 
| 
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
 eberlm parents: 
61585diff
changeset | 4701 | by (rule order_tendstoD) | 
| 60501 | 4702 | then obtain i where "inverse (2 ^ i) < e" | 
| 4703 | by (auto simp: eventually_sequentially) | |
| 4704 | have "eventually (\<lambda>x. M i \<le> x) sequentially" | |
| 4705 | by (auto simp: eventually_sequentially) | |
| 54452 | 4706 | then show "eventually (\<lambda>x. dist (X x) (Abs_fps (\<lambda>i. X (M i) $ i)) < e) sequentially" | 
| 51107 | 4707 | proof eventually_elim | 
| 52902 | 4708 | fix x | 
| 60501 | 4709 | assume x: "M i \<le> x" | 
| 4710 | have "X (M i) $ j = X (M j) $ j" if "j \<le> i" for j | |
| 4711 | using M that by (metis nat_le_linear) | |
| 4712 | with x have "dist (X x) (Abs_fps (\<lambda>j. X (M j) $ j)) < inverse (2 ^ i)" | |
| 51107 | 4713 | using M by (force simp: dist_less_eq_nth_equal) | 
| 60500 | 4714 | also note \<open>inverse (2 ^ i) < e\<close> | 
| 51107 | 4715 | finally show "dist (X x) (Abs_fps (\<lambda>j. X (M j) $ j)) < e" . | 
| 4716 | qed | |
| 4717 | qed | |
| 4718 | qed | |
| 4719 | qed | |
| 4720 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 4721 | end |