| author | wenzelm | 
| Fri, 05 Oct 2012 12:00:28 +0200 | |
| changeset 49708 | 295ec55e7baa | 
| parent 48757 | 1232760e208e | 
| child 49834 | b27bbb021df1 | 
| permissions | -rw-r--r-- | 
| 41959 | 1 | (* Title: HOL/Library/Formal_Power_Series.thy | 
| 29687 | 2 | Author: Amine Chaieb, University of Cambridge | 
| 3 | *) | |
| 4 | ||
| 5 | header{* A formalization of formal power series *}
 | |
| 6 | ||
| 7 | theory Formal_Power_Series | |
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 8 | imports Complex_Main Binomial | 
| 29687 | 9 | begin | 
| 10 | ||
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 11 | |
| 29906 | 12 | subsection {* The type of formal power series*}
 | 
| 29687 | 13 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 14 | typedef (open) 'a fps = "{f :: nat \<Rightarrow> 'a. True}"
 | 
| 
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 | |
| 48757 | 29 | text{* Definition of the basic elements 0 and 1 and the basic operations of addition,
 | 
| 30 | negation and multiplication *} | |
| 29687 | 31 | |
| 36409 | 32 | instantiation fps :: (zero) zero | 
| 29687 | 33 | begin | 
| 34 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 35 | definition fps_zero_def: | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 36 | "0 = Abs_fps (\<lambda>n. 0)" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 37 | |
| 29687 | 38 | instance .. | 
| 39 | end | |
| 40 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 41 | lemma fps_zero_nth [simp]: "0 $ n = 0" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 42 | unfolding fps_zero_def by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 43 | |
| 36409 | 44 | instantiation fps :: ("{one, zero}") one
 | 
| 29687 | 45 | begin | 
| 46 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 47 | definition fps_one_def: | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 48 | "1 = Abs_fps (\<lambda>n. if n = 0 then 1 else 0)" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 49 | |
| 29687 | 50 | instance .. | 
| 51 | end | |
| 52 | ||
| 30488 | 53 | 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 | 54 | unfolding fps_one_def by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 55 | |
| 29687 | 56 | instantiation fps :: (plus) plus | 
| 57 | begin | |
| 58 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 59 | definition fps_plus_def: | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 60 | "op + = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n + g $ n))" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 61 | |
| 29687 | 62 | instance .. | 
| 63 | end | |
| 64 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 65 | 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 | 66 | unfolding fps_plus_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 :: (minus) minus | 
| 29687 | 69 | begin | 
| 70 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 71 | definition fps_minus_def: | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 72 | "op - = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n - g $ n))" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 73 | |
| 29687 | 74 | instance .. | 
| 75 | end | |
| 76 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 77 | 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 | 78 | unfolding fps_minus_def by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 79 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 80 | instantiation fps :: (uminus) uminus | 
| 29687 | 81 | begin | 
| 82 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 83 | definition fps_uminus_def: | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 84 | "uminus = (\<lambda>f. Abs_fps (\<lambda>n. - (f $ n)))" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 85 | |
| 29687 | 86 | instance .. | 
| 87 | end | |
| 88 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 89 | 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 | 90 | unfolding fps_uminus_def by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 91 | |
| 29687 | 92 | instantiation fps :: ("{comm_monoid_add, times}")  times
 | 
| 93 | begin | |
| 94 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 95 | definition fps_times_def: | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 96 | "op * = (\<lambda>f g. Abs_fps (\<lambda>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 | 97 | |
| 29687 | 98 | instance .. | 
| 99 | end | |
| 100 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 101 | 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 | 102 | unfolding fps_times_def by simp | 
| 29687 | 103 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 104 | declare atLeastAtMost_iff[presburger] | 
| 29687 | 105 | declare Bex_def[presburger] | 
| 106 | declare Ball_def[presburger] | |
| 107 | ||
| 29913 | 108 | lemma mult_delta_left: | 
| 109 | fixes x y :: "'a::mult_zero" | |
| 110 | shows "(if b then x else 0) * y = (if b then x * y else 0)" | |
| 111 | by simp | |
| 112 | ||
| 113 | lemma mult_delta_right: | |
| 114 | fixes x y :: "'a::mult_zero" | |
| 115 | shows "x * (if b then y else 0) = (if b then x * y else 0)" | |
| 116 | by simp | |
| 117 | ||
| 29687 | 118 | lemma cond_value_iff: "f (if b then x else y) = (if b then f x else f y)" | 
| 119 | by auto | |
| 120 | lemma cond_application_beta: "(if b then f else g) x = (if b then f x else g x)" | |
| 121 | by auto | |
| 122 | ||
| 30488 | 123 | subsection{* Formal power series form a commutative ring with unity, if the range of sequences
 | 
| 29687 | 124 | they represent is a commutative ring with unity*} | 
| 125 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 126 | instance fps :: (semigroup_add) semigroup_add | 
| 29687 | 127 | proof | 
| 128 | fix a b c :: "'a fps" show "a + b + c = a + (b + c)" | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 129 | by (simp add: fps_ext add_assoc) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 130 | qed | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 131 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 132 | instance fps :: (ab_semigroup_add) ab_semigroup_add | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 133 | proof | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 134 | fix a b :: "'a fps" show "a + b = b + a" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 135 | by (simp add: fps_ext add_commute) | 
| 29687 | 136 | qed | 
| 137 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 138 | lemma fps_mult_assoc_lemma: | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 139 | fixes k :: nat and f :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> 'a::comm_monoid_add" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 140 | 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 | 141 | (\<Sum>j=0..k. \<Sum>i=0..k - j. f j i (n - j - i))" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 142 | proof (induct k) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 143 | case 0 show ?case by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 144 | next | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 145 | case (Suc k) thus ?case | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 146 | by (simp add: Suc_diff_le setsum_addf add_assoc | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 147 | cong: strong_setsum_cong) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 148 | qed | 
| 29687 | 149 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 150 | instance fps :: (semiring_0) semigroup_mult | 
| 29687 | 151 | proof | 
| 152 | fix a b c :: "'a fps" | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 153 | show "(a * b) * c = a * (b * c)" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 154 | proof (rule fps_ext) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 155 | fix n :: nat | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 156 | 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 | 157 | (\<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 | 158 | by (rule fps_mult_assoc_lemma) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 159 | thus "((a * b) * c) $ n = (a * (b * c)) $ n" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 160 | by (simp add: fps_mult_nth setsum_right_distrib | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 161 | setsum_left_distrib mult_assoc) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 162 | qed | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 163 | qed | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 164 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 165 | lemma fps_mult_commute_lemma: | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 166 | fixes n :: nat and f :: "nat \<Rightarrow> nat \<Rightarrow> 'a::comm_monoid_add" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 167 | shows "(\<Sum>i=0..n. f i (n - i)) = (\<Sum>i=0..n. f (n - i) i)" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 168 | proof (rule setsum_reindex_cong) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 169 |   show "inj_on (\<lambda>i. n - i) {0..n}"
 | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 170 | by (rule inj_onI) simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 171 |   show "{0..n} = (\<lambda>i. n - i) ` {0..n}"
 | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 172 | by (auto, rule_tac x="n - x" in image_eqI, simp_all) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 173 | next | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 174 |   fix i assume "i \<in> {0..n}"
 | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 175 | hence "n - (n - i) = i" by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 176 | thus "f (n - i) i = f (n - i) (n - (n - i))" by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 177 | qed | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 178 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 179 | instance fps :: (comm_semiring_0) ab_semigroup_mult | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 180 | proof | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 181 | fix a b :: "'a fps" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 182 | show "a * b = b * a" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 183 | proof (rule fps_ext) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 184 | fix n :: nat | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 185 | 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 | 186 | by (rule fps_mult_commute_lemma) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 187 | thus "(a * b) $ n = (b * a) $ n" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 188 | by (simp add: fps_mult_nth mult_commute) | 
| 29687 | 189 | qed | 
| 190 | qed | |
| 191 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 192 | instance fps :: (monoid_add) monoid_add | 
| 29687 | 193 | proof | 
| 194 | fix a :: "'a fps" show "0 + a = a " | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 195 | by (simp add: fps_ext) | 
| 29687 | 196 | next | 
| 197 | fix a :: "'a fps" show "a + 0 = a " | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 198 | by (simp add: fps_ext) | 
| 29687 | 199 | qed | 
| 200 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 201 | instance fps :: (comm_monoid_add) comm_monoid_add | 
| 29687 | 202 | proof | 
| 203 | fix a :: "'a fps" show "0 + a = a " | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 204 | by (simp add: fps_ext) | 
| 29687 | 205 | qed | 
| 206 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 207 | instance fps :: (semiring_1) monoid_mult | 
| 29687 | 208 | proof | 
| 209 | fix a :: "'a fps" show "1 * a = a" | |
| 29913 | 210 | by (simp add: fps_ext fps_mult_nth mult_delta_left setsum_delta) | 
| 29687 | 211 | next | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 212 | fix a :: "'a fps" show "a * 1 = a" | 
| 29913 | 213 | by (simp add: fps_ext fps_mult_nth mult_delta_right setsum_delta') | 
| 29687 | 214 | qed | 
| 215 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 216 | instance fps :: (cancel_semigroup_add) cancel_semigroup_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 c :: "'a fps" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 219 | assume "a + b = a + c" then show "b = c" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 220 | by (simp add: expand_fps_eq) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 221 | next | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 222 | fix a b c :: "'a fps" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 223 | assume "b + a = c + a" then show "b = c" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 224 | by (simp add: expand_fps_eq) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 225 | qed | 
| 29687 | 226 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 227 | 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 | 228 | proof | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 229 | fix a b c :: "'a fps" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 230 | assume "a + b = a + c" then show "b = c" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 231 | by (simp add: expand_fps_eq) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 232 | qed | 
| 29687 | 233 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 234 | 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 | 235 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 236 | instance fps :: (group_add) group_add | 
| 29687 | 237 | proof | 
| 238 | fix a :: "'a fps" show "- a + a = 0" | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 239 | by (simp add: fps_ext) | 
| 29687 | 240 | next | 
| 241 | fix a b :: "'a fps" show "a - b = a + - b" | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 242 | by (simp add: fps_ext diff_minus) | 
| 29687 | 243 | qed | 
| 244 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 245 | instance fps :: (ab_group_add) ab_group_add | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 246 | proof | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 247 | fix a :: "'a fps" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 248 | show "- a + a = 0" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 249 | by (simp add: fps_ext) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 250 | next | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 251 | fix a b :: "'a fps" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 252 | show "a - b = a + - b" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 253 | by (simp add: fps_ext) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 254 | qed | 
| 29687 | 255 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 256 | instance fps :: (zero_neq_one) zero_neq_one | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 257 | by default (simp add: expand_fps_eq) | 
| 29687 | 258 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 259 | instance fps :: (semiring_0) semiring | 
| 29687 | 260 | proof | 
| 261 | fix a b c :: "'a fps" | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 262 | show "(a + b) * c = a * c + b * c" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 263 | by (simp add: expand_fps_eq fps_mult_nth left_distrib setsum_addf) | 
| 29687 | 264 | next | 
| 265 | fix a b c :: "'a fps" | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 266 | show "a * (b + c) = a * b + a * c" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 267 | by (simp add: expand_fps_eq fps_mult_nth right_distrib setsum_addf) | 
| 29687 | 268 | qed | 
| 269 | ||
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 270 | instance fps :: (semiring_0) semiring_0 | 
| 29687 | 271 | proof | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 272 | fix a:: "'a fps" show "0 * a = 0" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 273 | by (simp add: fps_ext fps_mult_nth) | 
| 29687 | 274 | next | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 275 | fix a:: "'a fps" show "a * 0 = 0" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 276 | by (simp add: fps_ext fps_mult_nth) | 
| 29687 | 277 | qed | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 278 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 279 | instance fps :: (semiring_0_cancel) semiring_0_cancel .. | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 280 | |
| 29906 | 281 | subsection {* Selection of the nth power of the implicit variable in the infinite sum*}
 | 
| 29687 | 282 | |
| 283 | 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 | 284 | by (simp add: expand_fps_eq) | 
| 29687 | 285 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 286 | lemma fps_nonzero_nth_minimal: | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 287 | "f \<noteq> 0 \<longleftrightarrow> (\<exists>n. f $ n \<noteq> 0 \<and> (\<forall>m<n. f $ m = 0))" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 288 | proof | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 289 | let ?n = "LEAST n. f $ n \<noteq> 0" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 290 | assume "f \<noteq> 0" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 291 | then have "\<exists>n. f $ n \<noteq> 0" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 292 | by (simp add: fps_nonzero_nth) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 293 | then have "f $ ?n \<noteq> 0" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 294 | by (rule LeastI_ex) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 295 | moreover have "\<forall>m<?n. f $ m = 0" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 296 | by (auto dest: not_less_Least) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 297 | ultimately have "f $ ?n \<noteq> 0 \<and> (\<forall>m<?n. f $ m = 0)" .. | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 298 | then show "\<exists>n. f $ n \<noteq> 0 \<and> (\<forall>m<n. f $ m = 0)" .. | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 299 | next | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 300 | assume "\<exists>n. f $ n \<noteq> 0 \<and> (\<forall>m<n. f $ m = 0)" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 301 | then show "f \<noteq> 0" by (auto simp add: expand_fps_eq) | 
| 29687 | 302 | qed | 
| 303 | ||
| 304 | 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 | 305 | by (rule expand_fps_eq) | 
| 29687 | 306 | |
| 30488 | 307 | lemma fps_setsum_nth: "(setsum f S) $ n = setsum (\<lambda>k. (f k) $ n) S" | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 308 | proof (cases "finite S") | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 309 | assume "\<not> finite S" then show ?thesis by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 310 | next | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 311 | assume "finite S" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 312 | then show ?thesis by (induct set: finite) auto | 
| 29687 | 313 | qed | 
| 314 | ||
| 29906 | 315 | subsection{* Injection of the basic ring elements and multiplication by scalars *}
 | 
| 29687 | 316 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 317 | definition | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 318 | "fps_const c = Abs_fps (\<lambda>n. if n = 0 then c else 0)" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 319 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 320 | 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 | 321 | unfolding fps_const_def by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 322 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 323 | 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 | 324 | by (simp add: fps_ext) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 325 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 326 | 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 | 327 | by (simp add: fps_ext) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 328 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 329 | 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 | 330 | by (simp add: fps_ext) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 331 | |
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 332 | lemma fps_const_add [simp]: "fps_const (c::'a\<Colon>monoid_add) + fps_const d = fps_const (c + d)" | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 333 | by (simp add: fps_ext) | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 334 | lemma fps_const_sub [simp]: "fps_const (c::'a\<Colon>group_add) - fps_const d = fps_const (c - d)" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 335 | by (simp add: fps_ext) | 
| 29687 | 336 | lemma fps_const_mult[simp]: "fps_const (c::'a\<Colon>ring) * fps_const d = fps_const (c * d)" | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 337 | by (simp add: fps_eq_iff fps_mult_nth setsum_0') | 
| 29687 | 338 | |
| 48757 | 339 | lemma fps_const_add_left: "fps_const (c::'a\<Colon>monoid_add) + f = | 
| 340 | 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 | 341 | by (simp add: fps_ext) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 342 | |
| 48757 | 343 | lemma fps_const_add_right: "f + fps_const (c::'a\<Colon>monoid_add) = | 
| 344 | 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 | 345 | by (simp add: fps_ext) | 
| 29687 | 346 | |
| 347 | lemma fps_const_mult_left: "fps_const (c::'a\<Colon>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 | 348 | unfolding fps_eq_iff fps_mult_nth | 
| 29913 | 349 | by (simp add: fps_const_def mult_delta_left setsum_delta) | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 350 | |
| 29687 | 351 | lemma fps_const_mult_right: "f * fps_const (c::'a\<Colon>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 | 352 | unfolding fps_eq_iff fps_mult_nth | 
| 29913 | 353 | by (simp add: fps_const_def mult_delta_right setsum_delta') | 
| 29687 | 354 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 355 | lemma fps_mult_left_const_nth [simp]: "(fps_const (c::'a::semiring_1) * f)$n = c* f$n" | 
| 29913 | 356 | by (simp add: fps_mult_nth mult_delta_left setsum_delta) | 
| 29687 | 357 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 358 | lemma fps_mult_right_const_nth [simp]: "(f * fps_const (c::'a::semiring_1))$n = f$n * c" | 
| 29913 | 359 | by (simp add: fps_mult_nth mult_delta_right setsum_delta') | 
| 29687 | 360 | |
| 29906 | 361 | subsection {* Formal power series form an integral domain*}
 | 
| 29687 | 362 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 363 | instance fps :: (ring) ring .. | 
| 29687 | 364 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 365 | instance fps :: (ring_1) ring_1 | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 366 | by (intro_classes, auto simp add: diff_minus left_distrib) | 
| 29687 | 367 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 368 | instance fps :: (comm_ring_1) comm_ring_1 | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 369 | by (intro_classes, auto simp add: diff_minus left_distrib) | 
| 29687 | 370 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 371 | instance fps :: (ring_no_zero_divisors) ring_no_zero_divisors | 
| 29687 | 372 | proof | 
| 373 | fix a b :: "'a fps" | |
| 374 | assume a0: "a \<noteq> 0" and b0: "b \<noteq> 0" | |
| 375 | then obtain i j where i: "a$i\<noteq>0" "\<forall>k<i. a$k=0" | |
| 376 | and j: "b$j \<noteq>0" "\<forall>k<j. b$k =0" unfolding fps_nonzero_nth_minimal | |
| 377 | by blast+ | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 378 | have "(a * b) $ (i+j) = (\<Sum>k=0..i+j. a$k * b$(i+j-k))" | 
| 29687 | 379 | by (rule fps_mult_nth) | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 380 |   also have "\<dots> = (a$i * b$(i+j-i)) + (\<Sum>k\<in>{0..i+j}-{i}. a$k * b$(i+j-k))"
 | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 381 | by (rule setsum_diff1') simp_all | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 382 |   also have "(\<Sum>k\<in>{0..i+j}-{i}. a$k * b$(i+j-k)) = 0"
 | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 383 | proof (rule setsum_0' [rule_format]) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 384 |       fix k assume "k \<in> {0..i+j} - {i}"
 | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 385 | then have "k < i \<or> i+j-k < j" by auto | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 386 | then show "a$k * b$(i+j-k) = 0" using i j by auto | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 387 | qed | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 388 | also have "a$i * b$(i+j-i) + 0 = a$i * b$j" by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 389 | also have "a$i * b$j \<noteq> 0" using i j by simp | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 390 | finally have "(a*b) $ (i+j) \<noteq> 0" . | 
| 29687 | 391 | then show "a*b \<noteq> 0" unfolding fps_nonzero_nth by blast | 
| 392 | qed | |
| 393 | ||
| 36311 
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
 haftmann parents: 
36309diff
changeset | 394 | 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 | 395 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 396 | instance fps :: (idom) idom .. | 
| 29687 | 397 | |
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 398 | lemma numeral_fps_const: "numeral k = fps_const (numeral k)" | 
| 48757 | 399 | 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 | 400 | fps_const_add [symmetric]) | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 401 | |
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 402 | lemma neg_numeral_fps_const: "neg_numeral k = fps_const (neg_numeral k)" | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 403 | by (simp only: neg_numeral_def numeral_fps_const fps_const_neg) | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 404 | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 405 | subsection{* The eXtractor series X*}
 | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 406 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 407 | lemma minus_one_power_iff: "(- (1::'a :: {comm_ring_1})) ^ n = (if even n then 1 else - 1)"
 | 
| 48757 | 408 | by (induct n) auto | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 409 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 410 | definition "X = Abs_fps (\<lambda>n. if n = 1 then 1 else 0)" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 411 | lemma X_mult_nth[simp]: "(X * (f :: ('a::semiring_1) fps)) $n = (if n = 0 then 0 else f $ (n - 1))"
 | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 412 | proof- | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 413 |   {assume n: "n \<noteq> 0"
 | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 414 | have "(X * f) $n = (\<Sum>i = 0..n. X $ i * f $ (n - i))" by (simp add: fps_mult_nth) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 415 | also have "\<dots> = f $ (n - 1)" | 
| 46757 | 416 | using n by (simp add: X_def mult_delta_left setsum_delta) | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 417 | finally have ?thesis using n by simp } | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 418 | moreover | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 419 |   {assume n: "n=0" hence ?thesis by (simp add: fps_mult_nth X_def)}
 | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 420 | ultimately show ?thesis by blast | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 421 | qed | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 422 | |
| 48757 | 423 | lemma X_mult_right_nth[simp]: | 
| 424 |     "((f :: ('a::comm_semiring_1) fps) * X) $n = (if n = 0 then 0 else f $ (n - 1))"
 | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 425 | by (metis X_mult_nth mult_commute) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 426 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 427 | lemma X_power_iff: "X^k = Abs_fps (\<lambda>n. if n = k then (1::'a::comm_ring_1) else 0)" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 428 | proof(induct k) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 429 | case 0 thus ?case by (simp add: X_def fps_eq_iff) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 430 | next | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 431 | case (Suc k) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 432 |   {fix m
 | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 433 | have "(X^Suc k) $ m = (if m = 0 then (0::'a) else (X^k) $ (m - 1))" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 434 | by (simp add: power_Suc del: One_nat_def) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 435 | then have "(X^Suc k) $ m = (if m = Suc k then (1::'a) else 0)" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 436 | using Suc.hyps by (auto cong del: if_weak_cong)} | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 437 | then show ?case by (simp add: fps_eq_iff) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 438 | qed | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 439 | |
| 48757 | 440 | lemma X_power_mult_nth: | 
| 441 |     "(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 | 442 | apply (induct k arbitrary: n) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 443 | apply (simp) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 444 | unfolding power_Suc mult_assoc | 
| 48757 | 445 | apply (case_tac n) | 
| 446 | apply auto | |
| 447 | done | |
| 448 | ||
| 449 | lemma X_power_mult_right_nth: | |
| 450 |     "((f :: ('a::comm_ring_1) fps) * X^k) $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 | 451 | by (metis X_power_mult_nth mult_commute) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 452 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 453 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 454 | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 455 | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 456 | subsection{* Formal Power series form a metric space *}
 | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 457 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 458 | definition (in dist) ball_def: "ball x r = {y. dist y x < r}"
 | 
| 48757 | 459 | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 460 | instantiation fps :: (comm_ring_1) dist | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 461 | begin | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 462 | |
| 48757 | 463 | definition dist_fps_def: | 
| 464 | "dist (a::'a fps) b = (if (\<exists>n. a$n \<noteq> b$n) then inverse (2 ^ The (leastP (\<lambda>n. a$n \<noteq> b$n))) else 0)" | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 465 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 466 | lemma dist_fps_ge0: "dist (a::'a fps) b \<ge> 0" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 467 | by (simp add: dist_fps_def) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 468 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 469 | lemma dist_fps_sym: "dist (a::'a fps) b = dist b a" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 470 | apply (auto simp add: dist_fps_def) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 471 | apply (rule cong[OF refl, where x="(\<lambda>n\<Colon>nat. a $ n \<noteq> b $ n)"]) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 472 | apply (rule ext) | 
| 48757 | 473 | apply auto | 
| 474 | done | |
| 475 | ||
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 476 | instance .. | 
| 48757 | 477 | |
| 30746 | 478 | end | 
| 479 | ||
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 480 | lemma fps_nonzero_least_unique: assumes a0: "a \<noteq> 0" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 481 | shows "\<exists>! n. leastP (\<lambda>n. a$n \<noteq> 0) n" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 482 | proof- | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 483 | from fps_nonzero_nth_minimal[of a] a0 | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 484 | obtain n where n: "a$n \<noteq> 0" "\<forall>m < n. a$m = 0" by blast | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 485 | from n have ln: "leastP (\<lambda>n. a$n \<noteq> 0) n" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 486 | by (auto simp add: leastP_def setge_def not_le[symmetric]) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 487 | moreover | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 488 |   {fix m assume "leastP (\<lambda>n. a$n \<noteq> 0) m"
 | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 489 | then have "m = n" using ln | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 490 | apply (auto simp add: leastP_def setge_def) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 491 | apply (erule allE[where x=n]) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 492 | apply (erule allE[where x=m]) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 493 | by simp} | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 494 | ultimately show ?thesis by blast | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 495 | qed | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 496 | |
| 48757 | 497 | lemma fps_eq_least_unique: | 
| 498 |   assumes ab: "(a::('a::ab_group_add) fps) \<noteq> b"
 | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 499 | shows "\<exists>! n. leastP (\<lambda>n. a$n \<noteq> b$n) n" | 
| 48757 | 500 | using fps_nonzero_least_unique[of "a - b"] ab | 
| 501 | by auto | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 502 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 503 | instantiation fps :: (comm_ring_1) metric_space | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 504 | begin | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 505 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 506 | definition open_fps_def: "open (S :: 'a fps set) = (\<forall>a \<in> S. \<exists>r. r >0 \<and> ball a r \<subseteq> S)" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 507 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 508 | instance | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 509 | proof | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 510 | fix S :: "'a fps set" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 511 | show "open S = (\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S)" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 512 | by (auto simp add: open_fps_def ball_def subset_eq) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 513 | next | 
| 48757 | 514 |   {
 | 
| 515 | fix a b :: "'a fps" | |
| 516 |     {
 | |
| 517 | assume ab: "a = b" | |
| 518 | then have "\<not> (\<exists>n. a$n \<noteq> b$n)" by simp | |
| 519 | then have "dist a b = 0" by (simp add: dist_fps_def) | |
| 520 | } | |
| 521 | moreover | |
| 522 |     {
 | |
| 523 | assume d: "dist a b = 0" | |
| 524 | then have "\<forall>n. a$n = b$n" | |
| 525 | by - (rule ccontr, simp add: dist_fps_def) | |
| 526 | then have "a = b" by (simp add: fps_eq_iff) | |
| 527 | } | |
| 528 | ultimately show "dist a b =0 \<longleftrightarrow> a = b" by blast | |
| 529 | } | |
| 530 | note th = this | |
| 531 | from th have th'[simp]: "\<And>a::'a fps. dist a a = 0" by simp | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 532 | fix a b c :: "'a fps" | 
| 48757 | 533 |   {
 | 
| 534 | assume ab: "a = b" then have d0: "dist a b = 0" unfolding th . | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 535 | then have "dist a b \<le> dist a c + dist b c" | 
| 48757 | 536 | using dist_fps_ge0[of a c] dist_fps_ge0[of b c] by simp | 
| 537 | } | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 538 | moreover | 
| 48757 | 539 |   {
 | 
| 540 | assume c: "c = a \<or> c = b" | |
| 541 | then have "dist a b \<le> dist a c + dist b c" | |
| 542 | by (cases "c=a") (simp_all add: th dist_fps_sym) | |
| 543 | } | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 544 | moreover | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 545 |   {assume ab: "a \<noteq> b" and ac: "a \<noteq> c" and bc: "b \<noteq> c"
 | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 546 | let ?P = "\<lambda>a b n. a$n \<noteq> b$n" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 547 | from fps_eq_least_unique[OF ab] fps_eq_least_unique[OF ac] | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 548 | fps_eq_least_unique[OF bc] | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 549 | obtain nab nac nbc where nab: "leastP (?P a b) nab" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 550 | and nac: "leastP (?P a c) nac" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 551 | and nbc: "leastP (?P b c) nbc" by blast | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 552 | from nab have nab': "\<And>m. m < nab \<Longrightarrow> a$m = b$m" "a$nab \<noteq> b$nab" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 553 | by (auto simp add: leastP_def setge_def) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 554 | from nac have nac': "\<And>m. m < nac \<Longrightarrow> a$m = c$m" "a$nac \<noteq> c$nac" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 555 | by (auto simp add: leastP_def setge_def) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 556 | from nbc have nbc': "\<And>m. m < nbc \<Longrightarrow> b$m = c$m" "b$nbc \<noteq> c$nbc" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 557 | by (auto simp add: leastP_def setge_def) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 558 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 559 | have th0: "\<And>(a::'a fps) b. a \<noteq> b \<longleftrightarrow> (\<exists>n. a$n \<noteq> b$n)" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 560 | by (simp add: fps_eq_iff) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 561 | from ab ac bc nab nac nbc | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 562 | have dab: "dist a b = inverse (2 ^ nab)" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 563 | and dac: "dist a c = inverse (2 ^ nac)" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 564 | and dbc: "dist b c = inverse (2 ^ nbc)" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 565 | unfolding th0 | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 566 | apply (simp_all add: dist_fps_def) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 567 | apply (erule the1_equality[OF fps_eq_least_unique[OF ab]]) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 568 | apply (erule the1_equality[OF fps_eq_least_unique[OF ac]]) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 569 | by (erule the1_equality[OF fps_eq_least_unique[OF bc]]) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 570 | from ab ac bc have nz: "dist a b \<noteq> 0" "dist a c \<noteq> 0" "dist b c \<noteq> 0" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 571 | unfolding th by simp_all | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 572 | from nz have pos: "dist a b > 0" "dist a c > 0" "dist b c > 0" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 573 | using dist_fps_ge0[of a b] dist_fps_ge0[of a c] dist_fps_ge0[of b c] | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 574 | by auto | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 575 | have th1: "\<And>n. (2::real)^n >0" by auto | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 576 |     {assume h: "dist a b > dist a c + dist b c"
 | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 577 | then have gt: "dist a b > dist a c" "dist a b > dist b c" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 578 | using pos by auto | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 579 | from gt have gtn: "nab < nbc" "nab < nac" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 580 | unfolding dab dbc dac by (auto simp add: th1) | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 581 | from nac'(1)[OF gtn(2)] nbc'(1)[OF gtn(1)] | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 582 | have "a$nab = b$nab" by simp | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 583 | with nab'(2) have False by simp} | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 584 | then have "dist a b \<le> dist a c + dist b c" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 585 | by (auto simp add: not_le[symmetric]) } | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 586 | ultimately show "dist a b \<le> dist a c + dist b c" by blast | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 587 | qed | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 588 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 589 | end | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 590 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 591 | text{* The infinite sums and justification of the notation in textbooks*}
 | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 592 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 593 | lemma reals_power_lt_ex: assumes xp: "x > 0" and y1: "(y::real) > 1" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 594 | shows "\<exists>k>0. (1/y)^k < x" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 595 | proof- | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 596 | have yp: "y > 0" using y1 by simp | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 597 | from reals_Archimedean2[of "max 0 (- log y x) + 1"] | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 598 | obtain k::nat where k: "real k > max 0 (- log y x) + 1" by blast | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 599 | from k have kp: "k > 0" by simp | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 600 | from k have "real k > - log y x" by simp | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 601 | then have "ln y * real k > - ln x" unfolding log_def | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 602 | using ln_gt_zero_iff[OF yp] y1 | 
| 36350 | 603 | by (simp add: minus_divide_left field_simps del:minus_divide_left[symmetric]) | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 604 | then have "ln y * real k + ln x > 0" by simp | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 605 | then have "exp (real k * ln y + ln x) > exp 0" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 606 | by (simp add: mult_ac) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 607 | then have "y ^ k * x > 1" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 608 | unfolding exp_zero exp_add exp_real_of_nat_mult | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 609 | exp_ln[OF xp] exp_ln[OF yp] by simp | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 610 | then have "x > (1/y)^k" using yp | 
| 36350 | 611 | by (simp add: field_simps nonzero_power_divide) | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 612 | then show ?thesis using kp by blast | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 613 | qed | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 614 | lemma X_nth[simp]: "X$n = (if n = 1 then 1 else 0)" by (simp add: X_def) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 615 | lemma X_power_nth[simp]: "(X^k) $n = (if n = k then 1 else (0::'a::comm_ring_1))" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 616 | by (simp add: X_power_iff) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 617 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 618 | |
| 48757 | 619 | lemma fps_sum_rep_nth: "(setsum (%i. fps_const(a$i)*X^i) {0..m})$n =
 | 
| 620 | (if n \<le> m then a$n else (0::'a::comm_ring_1))" | |
| 621 | apply (auto simp add: fps_eq_iff fps_setsum_nth X_power_nth cond_application_beta cond_value_iff | |
| 622 | cong del: if_weak_cong) | |
| 623 | apply (simp add: setsum_delta') | |
| 624 | done | |
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 625 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 626 | lemma fps_notation: | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 627 |   "(%n. setsum (%i. fps_const(a$i) * X^i) {0..n}) ----> a" (is "?s ----> a")
 | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 628 | proof- | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 629 |     {fix r:: real
 | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 630 | assume rp: "r > 0" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 631 | have th0: "(2::real) > 1" by simp | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 632 | from reals_power_lt_ex[OF rp th0] | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 633 | obtain n0 where n0: "(1/2)^n0 < r" "n0 > 0" by blast | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 634 |       {fix n::nat
 | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 635 | assume nn0: "n \<ge> n0" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 636 | then have thnn0: "(1/2)^n <= (1/2 :: real)^n0" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 637 | by (auto intro: power_decreasing) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 638 |         {assume "?s n = a" then have "dist (?s n) a < r" 
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 639 | unfolding dist_eq_0_iff[of "?s n" a, symmetric] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 640 | using rp by (simp del: dist_eq_0_iff)} | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 641 | moreover | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 642 |         {assume neq: "?s n \<noteq> a"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 643 | from fps_eq_least_unique[OF neq] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 644 | obtain k where k: "leastP (\<lambda>i. ?s n $ i \<noteq> a$i) k" by blast | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 645 | have th0: "\<And>(a::'a fps) b. a \<noteq> b \<longleftrightarrow> (\<exists>n. a$n \<noteq> b$n)" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 646 | by (simp add: fps_eq_iff) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 647 | from neq have dth: "dist (?s n) a = (1/2)^k" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 648 | unfolding th0 dist_fps_def | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 649 | unfolding the1_equality[OF fps_eq_least_unique[OF neq], OF k] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 650 | by (auto simp add: inverse_eq_divide power_divide) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 651 | |
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 652 | from k have kn: "k > n" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 653 | by (simp add: leastP_def setge_def fps_sum_rep_nth split:split_if_asm) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 654 | then have "dist (?s n) a < (1/2)^n" unfolding dth | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 655 | by (auto intro: power_strict_decreasing) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 656 | also have "\<dots> <= (1/2)^n0" using nn0 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 657 | by (auto intro: power_decreasing) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 658 | also have "\<dots> < r" using n0 by simp | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 659 | finally have "dist (?s n) a < r" .} | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 660 | ultimately have "dist (?s n) a < r" by blast} | 
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 661 | then have "\<exists>n0. \<forall> n \<ge> n0. dist (?s n) a < r " by blast} | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 662 | then show ?thesis unfolding LIMSEQ_def by blast | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 663 | qed | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 664 | |
| 29906 | 665 | subsection{* Inverses of formal power series *}
 | 
| 29687 | 666 | |
| 667 | declare setsum_cong[fundef_cong] | |
| 668 | ||
| 36311 
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
 haftmann parents: 
36309diff
changeset | 669 | instantiation fps :: ("{comm_monoid_add, inverse, times, uminus}") inverse
 | 
| 29687 | 670 | begin | 
| 671 | ||
| 30488 | 672 | fun natfun_inverse:: "'a fps \<Rightarrow> nat \<Rightarrow> 'a" where | 
| 29687 | 673 | "natfun_inverse f 0 = inverse (f$0)" | 
| 30488 | 674 | | "natfun_inverse f n = - inverse (f$0) * setsum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n}"
 | 
| 29687 | 675 | |
| 30488 | 676 | definition fps_inverse_def: | 
| 36311 
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
 haftmann parents: 
36309diff
changeset | 677 | "inverse f = (if f $ 0 = 0 then 0 else Abs_fps (natfun_inverse f))" | 
| 
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
 haftmann parents: 
36309diff
changeset | 678 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 679 | definition fps_divide_def: "divide = (\<lambda>(f::'a fps) g. f * inverse g)" | 
| 36311 
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
 haftmann parents: 
36309diff
changeset | 680 | |
| 29687 | 681 | instance .. | 
| 36311 
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
 haftmann parents: 
36309diff
changeset | 682 | |
| 29687 | 683 | end | 
| 684 | ||
| 30488 | 685 | lemma fps_inverse_zero[simp]: | 
| 29687 | 686 |   "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 | 687 | by (simp add: fps_ext fps_inverse_def) | 
| 29687 | 688 | |
| 689 | 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 | 690 | apply (auto simp add: expand_fps_eq fps_inverse_def) | 
| 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 691 | by (case_tac n, auto) | 
| 29687 | 692 | |
| 36311 
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
 haftmann parents: 
36309diff
changeset | 693 | lemma inverse_mult_eq_1 [intro]: assumes f0: "f$0 \<noteq> (0::'a::field)" | 
| 29687 | 694 | shows "inverse f * f = 1" | 
| 695 | proof- | |
| 696 | have c: "inverse f * f = f * inverse f" by (simp add: mult_commute) | |
| 30488 | 697 | from f0 have ifn: "\<And>n. inverse f $ n = natfun_inverse f n" | 
| 29687 | 698 | by (simp add: fps_inverse_def) | 
| 699 | 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 | 700 | by (simp add: fps_mult_nth fps_inverse_def) | 
| 29687 | 701 |   {fix n::nat assume np: "n >0 "
 | 
| 702 |     from np have eq: "{0..n} = {0} \<union> {1 .. n}" by auto
 | |
| 703 |     have d: "{0} \<inter> {1 .. n} = {}" by auto
 | |
| 30488 | 704 | from f0 np have th0: "- (inverse f$n) = | 
| 29687 | 705 |       (setsum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n}) / (f$0)"
 | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 706 | by (cases n, simp, simp add: divide_inverse fps_inverse_def) | 
| 29687 | 707 | from th0[symmetric, unfolded nonzero_divide_eq_eq[OF f0]] | 
| 30488 | 708 |     have th1: "setsum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n} =
 | 
| 709 | - (f$0) * (inverse f)$n" | |
| 36350 | 710 | by (simp add: field_simps) | 
| 30488 | 711 | have "(f * inverse f) $ n = (\<Sum>i = 0..n. f $i * natfun_inverse f (n - i))" | 
| 29687 | 712 | unfolding fps_mult_nth ifn .. | 
| 30488 | 713 | also have "\<dots> = f$0 * natfun_inverse f n | 
| 29687 | 714 | + (\<Sum>i = 1..n. f$i * natfun_inverse f (n-i))" | 
| 46757 | 715 | by (simp add: eq) | 
| 29687 | 716 | also have "\<dots> = 0" unfolding th1 ifn by simp | 
| 717 | finally have "(inverse f * f)$n = 0" unfolding c . } | |
| 718 | with th0 show ?thesis by (simp add: fps_eq_iff) | |
| 719 | qed | |
| 720 | ||
| 721 | 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 | 722 | by (simp add: fps_inverse_def nonzero_imp_inverse_nonzero) | 
| 29687 | 723 | |
| 724 | lemma fps_inverse_eq_0_iff[simp]: "inverse f = (0:: ('a::field) fps) \<longleftrightarrow> f $0 = 0"
 | |
| 725 | proof- | |
| 726 |   {assume "f$0 = 0" hence "inverse f = 0" by (simp add: fps_inverse_def)}
 | |
| 727 | moreover | |
| 728 |   {assume h: "inverse f = 0" and c: "f $0 \<noteq> 0"
 | |
| 729 | from inverse_mult_eq_1[OF c] h have False by simp} | |
| 730 | ultimately show ?thesis by blast | |
| 731 | qed | |
| 732 | ||
| 48757 | 733 | lemma fps_inverse_idempotent[intro]: | 
| 734 | assumes f0: "f$0 \<noteq> (0::'a::field)" | |
| 29687 | 735 | shows "inverse (inverse f) = f" | 
| 736 | proof- | |
| 737 | from f0 have if0: "inverse f $ 0 \<noteq> 0" by simp | |
| 30488 | 738 | from inverse_mult_eq_1[OF f0] inverse_mult_eq_1[OF if0] | 
| 29687 | 739 | have th0: "inverse f * f = inverse f * inverse (inverse f)" by (simp add: mult_ac) | 
| 740 | then show ?thesis using f0 unfolding mult_cancel_left by simp | |
| 741 | qed | |
| 742 | ||
| 48757 | 743 | lemma fps_inverse_unique: | 
| 744 | assumes f0: "f$0 \<noteq> (0::'a::field)" and fg: "f*g = 1" | |
| 29687 | 745 | shows "inverse f = g" | 
| 746 | proof- | |
| 747 | from inverse_mult_eq_1[OF f0] fg | |
| 748 | have th0: "inverse f * f = g * f" by (simp add: mult_ac) | |
| 749 | then show ?thesis using f0 unfolding mult_cancel_right | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 750 | by (auto simp add: expand_fps_eq) | 
| 29687 | 751 | qed | 
| 752 | ||
| 30488 | 753 | lemma fps_inverse_gp: "inverse (Abs_fps(\<lambda>n. (1::'a::field))) | 
| 29687 | 754 | = Abs_fps (\<lambda>n. if n= 0 then 1 else if n=1 then - 1 else 0)" | 
| 755 | apply (rule fps_inverse_unique) | |
| 756 | apply simp | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 757 | apply (simp add: fps_eq_iff fps_mult_nth) | 
| 29687 | 758 | proof(clarsimp) | 
| 759 | fix n::nat assume n: "n > 0" | |
| 760 | let ?f = "\<lambda>i. if n = i then (1\<Colon>'a) else if n - i = 1 then - 1 else 0" | |
| 761 | let ?g = "\<lambda>i. if i = n then 1 else if i=n - 1 then - 1 else 0" | |
| 762 | let ?h = "\<lambda>i. if i=n - 1 then - 1 else 0" | |
| 30488 | 763 |   have th1: "setsum ?f {0..n} = setsum ?g {0..n}"
 | 
| 29687 | 764 | by (rule setsum_cong2) auto | 
| 30488 | 765 |   have th2: "setsum ?g {0..n - 1} = setsum ?h {0..n - 1}"
 | 
| 29687 | 766 | using n apply - by (rule setsum_cong2) auto | 
| 767 |   have eq: "{0 .. n} = {0.. n - 1} \<union> {n}" by auto
 | |
| 30488 | 768 |   from n have d: "{0.. n - 1} \<inter> {n} = {}" by auto
 | 
| 29687 | 769 |   have f: "finite {0.. n - 1}" "finite {n}" by auto
 | 
| 770 |   show "setsum ?f {0..n} = 0"
 | |
| 30488 | 771 | unfolding th1 | 
| 29687 | 772 | apply (simp add: setsum_Un_disjoint[OF f d, unfolded eq[symmetric]] del: One_nat_def) | 
| 773 | unfolding th2 | |
| 774 | by(simp add: setsum_delta) | |
| 775 | qed | |
| 776 | ||
| 29912 | 777 | subsection{* Formal Derivatives, and the MacLaurin theorem around 0*}
 | 
| 29687 | 778 | |
| 779 | definition "fps_deriv f = Abs_fps (\<lambda>n. of_nat (n + 1) * f $ (n + 1))" | |
| 780 | ||
| 48757 | 781 | lemma fps_deriv_nth[simp]: "fps_deriv f $ n = of_nat (n +1) * f $ (n+1)" | 
| 782 | by (simp add: fps_deriv_def) | |
| 783 | ||
| 784 | lemma fps_deriv_linear[simp]: | |
| 785 | "fps_deriv (fps_const (a::'a::comm_semiring_1) * f + fps_const b * g) = | |
| 786 | fps_const a * fps_deriv f + fps_const b * fps_deriv g" | |
| 36350 | 787 | unfolding fps_eq_iff fps_add_nth fps_const_mult_left fps_deriv_nth by (simp add: field_simps) | 
| 29687 | 788 | |
| 30488 | 789 | lemma fps_deriv_mult[simp]: | 
| 29687 | 790 |   fixes f :: "('a :: comm_ring_1) fps"
 | 
| 791 | shows "fps_deriv (f * g) = f * fps_deriv g + fps_deriv f * g" | |
| 792 | proof- | |
| 793 | let ?D = "fps_deriv" | |
| 794 |   {fix n::nat
 | |
| 795 |     let ?Zn = "{0 ..n}"
 | |
| 796 |     let ?Zn1 = "{0 .. n + 1}"
 | |
| 797 | let ?f = "\<lambda>i. i + 1" | |
| 798 |     have fi: "inj_on ?f {0..n}" by (simp add: inj_on_def)
 | |
| 799 |     have eq: "{1.. n+1} = ?f ` {0..n}" by auto
 | |
| 800 | let ?g = "\<lambda>i. of_nat (i+1) * g $ (i+1) * f $ (n - i) + | |
| 801 | of_nat (i+1)* f $ (i+1) * g $ (n - i)" | |
| 802 | let ?h = "\<lambda>i. of_nat i * g $ i * f $ ((n+1) - i) + | |
| 803 | of_nat i* f $ i * g $ ((n + 1) - i)" | |
| 804 |     {fix k assume k: "k \<in> {0..n}"
 | |
| 805 | have "?h (k + 1) = ?g k" using k by auto} | |
| 806 | note th0 = this | |
| 807 |     have eq': "{0..n +1}- {1 .. n+1} = {0}" by auto
 | |
| 808 | have s0: "setsum (\<lambda>i. of_nat i * f $ i * g $ (n + 1 - i)) ?Zn1 = setsum (\<lambda>i. of_nat (n + 1 - i) * f $ (n + 1 - i) * g $ i) ?Zn1" | |
| 809 | apply (rule setsum_reindex_cong[where f="\<lambda>i. n + 1 - i"]) | |
| 810 | apply (simp add: inj_on_def Ball_def) | |
| 811 | apply presburger | |
| 39302 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 nipkow parents: 
39198diff
changeset | 812 | apply (rule set_eqI) | 
| 29687 | 813 | apply (presburger add: image_iff) | 
| 814 | by simp | |
| 815 | have s1: "setsum (\<lambda>i. f $ i * g $ (n + 1 - i)) ?Zn1 = setsum (\<lambda>i. f $ (n + 1 - i) * g $ i) ?Zn1" | |
| 816 | apply (rule setsum_reindex_cong[where f="\<lambda>i. n + 1 - i"]) | |
| 817 | apply (simp add: inj_on_def Ball_def) | |
| 818 | apply presburger | |
| 39302 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 nipkow parents: 
39198diff
changeset | 819 | apply (rule set_eqI) | 
| 29687 | 820 | apply (presburger add: image_iff) | 
| 821 | by simp | |
| 822 | have "(f * ?D g + ?D f * g)$n = (?D g * f + ?D f * g)$n" by (simp only: mult_commute) | |
| 823 | also have "\<dots> = (\<Sum>i = 0..n. ?g i)" | |
| 824 | by (simp add: fps_mult_nth setsum_addf[symmetric]) | |
| 825 |     also have "\<dots> = setsum ?h {1..n+1}"
 | |
| 826 | using th0 setsum_reindex_cong[OF fi eq, of "?g" "?h"] by auto | |
| 827 |     also have "\<dots> = setsum ?h {0..n+1}"
 | |
| 828 | apply (rule setsum_mono_zero_left) | |
| 829 | apply simp | |
| 830 | apply (simp add: subset_eq) | |
| 831 | unfolding eq' | |
| 832 | by simp | |
| 833 | also have "\<dots> = (fps_deriv (f * g)) $ n" | |
| 834 | apply (simp only: fps_deriv_nth fps_mult_nth setsum_addf) | |
| 835 | unfolding s0 s1 | |
| 836 | unfolding setsum_addf[symmetric] setsum_right_distrib | |
| 837 | apply (rule setsum_cong2) | |
| 36350 | 838 | by (auto simp add: of_nat_diff field_simps) | 
| 29687 | 839 | finally have "(f * ?D g + ?D f * g) $ n = ?D (f*g) $ n" .} | 
| 30488 | 840 | then show ?thesis unfolding fps_eq_iff by auto | 
| 29687 | 841 | qed | 
| 842 | ||
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 843 | 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 | 844 | 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 | 845 | |
| 29687 | 846 | lemma fps_deriv_neg[simp]: "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 | 847 | by (simp add: fps_eq_iff fps_deriv_def) | 
| 29687 | 848 | lemma fps_deriv_add[simp]: "fps_deriv ((f:: ('a::comm_ring_1) fps) + g) = fps_deriv f + fps_deriv g"
 | 
| 849 | using fps_deriv_linear[of 1 f 1 g] by simp | |
| 850 | ||
| 851 | lemma fps_deriv_sub[simp]: "fps_deriv ((f:: ('a::comm_ring_1) fps) - g) = fps_deriv f - fps_deriv g"
 | |
| 30488 | 852 | unfolding diff_minus by simp | 
| 29687 | 853 | |
| 854 | 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 | 855 | by (simp add: fps_ext fps_deriv_def fps_const_def) | 
| 29687 | 856 | |
| 48757 | 857 | lemma fps_deriv_mult_const_left[simp]: | 
| 858 | "fps_deriv (fps_const (c::'a::comm_ring_1) * f) = fps_const c * fps_deriv f" | |
| 29687 | 859 | by simp | 
| 860 | ||
| 861 | lemma fps_deriv_0[simp]: "fps_deriv 0 = 0" | |
| 862 | by (simp add: fps_deriv_def fps_eq_iff) | |
| 863 | ||
| 864 | lemma fps_deriv_1[simp]: "fps_deriv 1 = 0" | |
| 865 | by (simp add: fps_deriv_def fps_eq_iff ) | |
| 866 | ||
| 48757 | 867 | lemma fps_deriv_mult_const_right[simp]: | 
| 868 | "fps_deriv (f * fps_const (c::'a::comm_ring_1)) = fps_deriv f * fps_const c" | |
| 29687 | 869 | by simp | 
| 870 | ||
| 48757 | 871 | lemma fps_deriv_setsum: | 
| 872 |   "fps_deriv (setsum f S) = setsum (\<lambda>i. fps_deriv (f i :: ('a::comm_ring_1) fps)) S"
 | |
| 29687 | 873 | proof- | 
| 48757 | 874 |   { assume "\<not> finite S" hence ?thesis by simp }
 | 
| 29687 | 875 | moreover | 
| 48757 | 876 |   {
 | 
| 877 | assume fS: "finite S" | |
| 878 | have ?thesis by (induct rule: finite_induct[OF fS]) simp_all | |
| 879 | } | |
| 29687 | 880 | ultimately show ?thesis by blast | 
| 881 | qed | |
| 882 | ||
| 48757 | 883 | lemma fps_deriv_eq_0_iff[simp]: | 
| 884 |   "fps_deriv f = 0 \<longleftrightarrow> (f = fps_const (f$0 :: 'a::{idom,semiring_char_0}))"
 | |
| 29687 | 885 | proof- | 
| 886 |   {assume "f= fps_const (f$0)" hence "fps_deriv f = fps_deriv (fps_const (f$0))" by simp
 | |
| 887 | hence "fps_deriv f = 0" by simp } | |
| 888 | moreover | |
| 889 |   {assume z: "fps_deriv f = 0"
 | |
| 890 | hence "\<forall>n. (fps_deriv f)$n = 0" by simp | |
| 891 | hence "\<forall>n. f$(n+1) = 0" by (simp del: of_nat_Suc of_nat_add One_nat_def) | |
| 892 | hence "f = fps_const (f$0)" | |
| 893 | apply (clarsimp simp add: fps_eq_iff fps_const_def) | |
| 894 | apply (erule_tac x="n - 1" in allE) | |
| 895 | by simp} | |
| 896 | ultimately show ?thesis by blast | |
| 897 | qed | |
| 898 | ||
| 30488 | 899 | lemma fps_deriv_eq_iff: | 
| 29687 | 900 |   fixes f:: "('a::{idom,semiring_char_0}) fps"
 | 
| 901 | shows "fps_deriv f = fps_deriv g \<longleftrightarrow> (f = fps_const(f$0 - g$0) + g)" | |
| 902 | proof- | |
| 903 | have "fps_deriv f = fps_deriv g \<longleftrightarrow> fps_deriv (f - g) = 0" by simp | |
| 904 | also have "\<dots> \<longleftrightarrow> f - g = fps_const ((f-g)$0)" unfolding fps_deriv_eq_0_iff .. | |
| 36350 | 905 | finally show ?thesis by (simp add: field_simps) | 
| 29687 | 906 | qed | 
| 907 | ||
| 48757 | 908 | lemma fps_deriv_eq_iff_ex: | 
| 909 |   "(fps_deriv f = fps_deriv g) \<longleftrightarrow> (\<exists>(c::'a::{idom,semiring_char_0}). f = fps_const c + g)"
 | |
| 910 | apply auto unfolding fps_deriv_eq_iff | |
| 911 | apply blast | |
| 912 | done | |
| 913 | ||
| 914 | ||
| 915 | fun fps_nth_deriv :: "nat \<Rightarrow> ('a::semiring_1) fps \<Rightarrow> 'a fps"
 | |
| 916 | where | |
| 29687 | 917 | "fps_nth_deriv 0 f = f" | 
| 918 | | "fps_nth_deriv (Suc n) f = fps_nth_deriv n (fps_deriv f)" | |
| 919 | ||
| 920 | lemma fps_nth_deriv_commute: "fps_nth_deriv (Suc n) f = fps_deriv (fps_nth_deriv n f)" | |
| 48757 | 921 | by (induct n arbitrary: f) auto | 
| 922 | ||
| 923 | lemma fps_nth_deriv_linear[simp]: | |
| 924 | "fps_nth_deriv n (fps_const (a::'a::comm_semiring_1) * f + fps_const b * g) = | |
| 925 | fps_const a * fps_nth_deriv n f + fps_const b * fps_nth_deriv n g" | |
| 926 | by (induct n arbitrary: f g) (auto simp add: fps_nth_deriv_commute) | |
| 927 | ||
| 928 | lemma fps_nth_deriv_neg[simp]: | |
| 929 |   "fps_nth_deriv n (- (f:: ('a:: comm_ring_1) fps)) = - (fps_nth_deriv n f)"
 | |
| 930 | by (induct n arbitrary: f) simp_all | |
| 931 | ||
| 932 | lemma fps_nth_deriv_add[simp]: | |
| 933 |   "fps_nth_deriv n ((f:: ('a::comm_ring_1) fps) + g) = fps_nth_deriv n f + fps_nth_deriv n g"
 | |
| 29687 | 934 | using fps_nth_deriv_linear[of n 1 f 1 g] by simp | 
| 935 | ||
| 48757 | 936 | lemma fps_nth_deriv_sub[simp]: | 
| 937 |   "fps_nth_deriv n ((f:: ('a::comm_ring_1) fps) - g) = fps_nth_deriv n f - fps_nth_deriv n g"
 | |
| 30488 | 938 | unfolding diff_minus fps_nth_deriv_add by simp | 
| 29687 | 939 | |
| 940 | lemma fps_nth_deriv_0[simp]: "fps_nth_deriv n 0 = 0" | |
| 48757 | 941 | by (induct n) simp_all | 
| 29687 | 942 | |
| 943 | lemma fps_nth_deriv_1[simp]: "fps_nth_deriv n 1 = (if n = 0 then 1 else 0)" | |
| 48757 | 944 | by (induct n) simp_all | 
| 945 | ||
| 946 | lemma fps_nth_deriv_const[simp]: | |
| 947 | "fps_nth_deriv n (fps_const c) = (if n = 0 then fps_const c else 0)" | |
| 948 | by (cases n) simp_all | |
| 949 | ||
| 950 | lemma fps_nth_deriv_mult_const_left[simp]: | |
| 951 | "fps_nth_deriv n (fps_const (c::'a::comm_ring_1) * f) = fps_const c * fps_nth_deriv n f" | |
| 29687 | 952 | using fps_nth_deriv_linear[of n "c" f 0 0 ] by simp | 
| 953 | ||
| 48757 | 954 | lemma fps_nth_deriv_mult_const_right[simp]: | 
| 955 | "fps_nth_deriv n (f * fps_const (c::'a::comm_ring_1)) = fps_nth_deriv n f * fps_const c" | |
| 29687 | 956 | using fps_nth_deriv_linear[of n "c" f 0 0] by (simp add: mult_commute) | 
| 957 | ||
| 48757 | 958 | lemma fps_nth_deriv_setsum: | 
| 959 |   "fps_nth_deriv n (setsum f S) = setsum (\<lambda>i. fps_nth_deriv n (f i :: ('a::comm_ring_1) fps)) S"
 | |
| 29687 | 960 | proof- | 
| 48757 | 961 |   { assume "\<not> finite S" hence ?thesis by simp }
 | 
| 29687 | 962 | moreover | 
| 48757 | 963 |   {
 | 
| 964 | assume fS: "finite S" | |
| 965 | have ?thesis by (induct rule: finite_induct[OF fS]) simp_all | |
| 966 | } | |
| 29687 | 967 | ultimately show ?thesis by blast | 
| 968 | qed | |
| 969 | ||
| 48757 | 970 | lemma fps_deriv_maclauren_0: | 
| 971 |   "(fps_nth_deriv k (f:: ('a::comm_semiring_1) fps)) $ 0 = of_nat (fact k) * f$(k)"
 | |
| 36350 | 972 | by (induct k arbitrary: f) (auto simp add: field_simps of_nat_mult) | 
| 29687 | 973 | |
| 29906 | 974 | subsection {* Powers*}
 | 
| 29687 | 975 | |
| 976 | lemma fps_power_zeroth_eq_one: "a$0 =1 \<Longrightarrow> a^n $ 0 = (1::'a::semiring_1)" | |
| 48757 | 977 | by (induct n) (auto simp add: expand_fps_eq fps_mult_nth) | 
| 29687 | 978 | |
| 979 | lemma fps_power_first_eq: "(a:: 'a::comm_ring_1 fps)$0 =1 \<Longrightarrow> a^n $ 1 = of_nat n * a$1" | |
| 980 | proof(induct n) | |
| 30960 | 981 | case 0 thus ?case by simp | 
| 29687 | 982 | next | 
| 983 | case (Suc n) | |
| 984 | note h = Suc.hyps[OF `a$0 = 1`] | |
| 30488 | 985 | show ?case unfolding power_Suc fps_mult_nth | 
| 36350 | 986 | using h `a$0 = 1` fps_power_zeroth_eq_one[OF `a$0=1`] by (simp add: field_simps) | 
| 29687 | 987 | qed | 
| 988 | ||
| 989 | lemma startsby_one_power:"a $ 0 = (1::'a::comm_ring_1) \<Longrightarrow> a^n $ 0 = 1" | |
| 48757 | 990 | by (induct n) (auto simp add: fps_mult_nth) | 
| 29687 | 991 | |
| 992 | lemma startsby_zero_power:"a $0 = (0::'a::comm_ring_1) \<Longrightarrow> n > 0 \<Longrightarrow> a^n $0 = 0" | |
| 48757 | 993 | by (induct n) (auto simp add: fps_mult_nth) | 
| 29687 | 994 | |
| 31021 | 995 | lemma startsby_power:"a $0 = (v::'a::{comm_ring_1}) \<Longrightarrow> a^n $0 = v^n"
 | 
| 48757 | 996 | by (induct n) (auto simp add: fps_mult_nth power_Suc) | 
| 29687 | 997 | |
| 998 | lemma startsby_zero_power_iff[simp]: | |
| 31021 | 999 |   "a^n $0 = (0::'a::{idom}) \<longleftrightarrow> (n \<noteq> 0 \<and> a$0 = 0)"
 | 
| 29687 | 1000 | apply (rule iffI) | 
| 48757 | 1001 | apply (induct n) | 
| 1002 | apply (auto simp add: fps_mult_nth) | |
| 1003 | apply (rule startsby_zero_power, simp_all) | |
| 1004 | done | |
| 29687 | 1005 | |
| 30488 | 1006 | lemma startsby_zero_power_prefix: | 
| 29687 | 1007 | assumes a0: "a $0 = (0::'a::idom)" | 
| 1008 | shows "\<forall>n < k. a ^ k $ n = 0" | |
| 30488 | 1009 | using a0 | 
| 29687 | 1010 | proof(induct k rule: nat_less_induct) | 
| 1011 | fix k assume H: "\<forall>m<k. a $0 = 0 \<longrightarrow> (\<forall>n<m. a ^ m $ n = 0)" and a0: "a $0 = (0\<Colon>'a)" | |
| 1012 | let ?ths = "\<forall>m<k. a ^ k $ m = 0" | |
| 1013 |   {assume "k = 0" then have ?ths by simp}
 | |
| 1014 | moreover | |
| 1015 |   {fix l assume k: "k = Suc l"
 | |
| 1016 |     {fix m assume mk: "m < k"
 | |
| 30488 | 1017 |       {assume "m=0" hence "a^k $ m = 0" using startsby_zero_power[of a k] k a0
 | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1018 | by simp} | 
| 29687 | 1019 | moreover | 
| 1020 |       {assume m0: "m \<noteq> 0"
 | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1021 | have "a ^k $ m = (a^l * a) $m" by (simp add: k power_Suc mult_commute) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1022 | also have "\<dots> = (\<Sum>i = 0..m. a ^ l $ i * a $ (m - i))" by (simp add: fps_mult_nth) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1023 | also have "\<dots> = 0" apply (rule setsum_0') | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1024 | apply auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1025 | apply (case_tac "aa = m") | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1026 | using a0 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1027 | apply simp | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1028 | apply (rule H[rule_format]) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1029 | using a0 k mk by auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1030 | finally have "a^k $ m = 0" .} | 
| 29687 | 1031 | ultimately have "a^k $ m = 0" by blast} | 
| 1032 | hence ?ths by blast} | |
| 1033 | ultimately show ?ths by (cases k, auto) | |
| 1034 | qed | |
| 1035 | ||
| 30488 | 1036 | lemma startsby_zero_setsum_depends: | 
| 29687 | 1037 | assumes a0: "a $0 = (0::'a::idom)" and kn: "n \<ge> k" | 
| 1038 |   shows "setsum (\<lambda>i. (a ^ i)$k) {0 .. n} = setsum (\<lambda>i. (a ^ i)$k) {0 .. k}"
 | |
| 1039 | apply (rule setsum_mono_zero_right) | |
| 1040 | using kn apply auto | |
| 1041 | apply (rule startsby_zero_power_prefix[rule_format, OF a0]) | |
| 1042 | by arith | |
| 1043 | ||
| 31021 | 1044 | lemma startsby_zero_power_nth_same: assumes a0: "a$0 = (0::'a::{idom})"
 | 
| 29687 | 1045 | shows "a^n $ n = (a$1) ^ n" | 
| 1046 | proof(induct n) | |
| 1047 | case 0 thus ?case by (simp add: power_0) | |
| 1048 | next | |
| 1049 | case (Suc n) | |
| 36350 | 1050 | have "a ^ Suc n $ (Suc n) = (a^n * a)$(Suc n)" by (simp add: field_simps power_Suc) | 
| 29687 | 1051 |   also have "\<dots> = setsum (\<lambda>i. a^n$i * a $ (Suc n - i)) {0.. Suc n}" by (simp add: fps_mult_nth)
 | 
| 1052 |   also have "\<dots> = setsum (\<lambda>i. a^n$i * a $ (Suc n - i)) {n .. Suc n}"
 | |
| 1053 | apply (rule setsum_mono_zero_right) | |
| 1054 | apply simp | |
| 1055 | apply clarsimp | |
| 1056 | apply clarsimp | |
| 1057 | apply (rule startsby_zero_power_prefix[rule_format, OF a0]) | |
| 1058 | apply arith | |
| 1059 | done | |
| 1060 | also have "\<dots> = a^n $ n * a$1" using a0 by simp | |
| 1061 | finally show ?case using Suc.hyps by (simp add: power_Suc) | |
| 1062 | qed | |
| 1063 | ||
| 1064 | lemma fps_inverse_power: | |
| 31021 | 1065 |   fixes a :: "('a::{field}) fps"
 | 
| 29687 | 1066 | shows "inverse (a^n) = inverse a ^ n" | 
| 1067 | proof- | |
| 1068 |   {assume a0: "a$0 = 0"
 | |
| 1069 | hence eq: "inverse a = 0" by (simp add: fps_inverse_def) | |
| 1070 |     {assume "n = 0" hence ?thesis by simp}
 | |
| 1071 | moreover | |
| 1072 |     {assume n: "n > 0"
 | |
| 30488 | 1073 | from startsby_zero_power[OF a0 n] eq a0 n have ?thesis | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1074 | by (simp add: fps_inverse_def)} | 
| 29687 | 1075 | ultimately have ?thesis by blast} | 
| 1076 | moreover | |
| 1077 |   {assume a0: "a$0 \<noteq> 0"
 | |
| 1078 | have ?thesis | |
| 1079 | apply (rule fps_inverse_unique) | |
| 1080 | apply (simp add: a0) | |
| 1081 | unfolding power_mult_distrib[symmetric] | |
| 1082 | apply (rule ssubst[where t = "a * inverse a" and s= 1]) | |
| 1083 | apply simp_all | |
| 1084 | apply (subst mult_commute) | |
| 1085 | by (rule inverse_mult_eq_1[OF a0])} | |
| 1086 | ultimately show ?thesis by blast | |
| 1087 | qed | |
| 1088 | ||
| 48757 | 1089 | lemma fps_deriv_power: | 
| 1090 | "fps_deriv (a ^ n) = fps_const (of_nat n :: 'a:: comm_ring_1) * fps_deriv a * a ^ (n - 1)" | |
| 1091 | apply (induct n) | |
| 1092 | apply (auto simp add: power_Suc field_simps fps_const_add[symmetric] simp del: fps_const_add) | |
| 1093 | apply (case_tac n) | |
| 1094 | apply (auto simp add: power_Suc field_simps) | |
| 1095 | done | |
| 29687 | 1096 | |
| 30488 | 1097 | lemma fps_inverse_deriv: | 
| 29687 | 1098 |   fixes a:: "('a :: field) fps"
 | 
| 1099 | assumes a0: "a$0 \<noteq> 0" | |
| 1100 | shows "fps_deriv (inverse a) = - fps_deriv a * inverse a ^ 2" | |
| 1101 | proof- | |
| 1102 | from inverse_mult_eq_1[OF a0] | |
| 1103 | have "fps_deriv (inverse a * a) = 0" by simp | |
| 1104 | hence "inverse a * fps_deriv a + fps_deriv (inverse a) * a = 0" by simp | |
| 1105 | hence "inverse a * (inverse a * fps_deriv a + fps_deriv (inverse a) * a) = 0" by simp | |
| 1106 | with inverse_mult_eq_1[OF a0] | |
| 1107 | have "inverse a ^ 2 * fps_deriv a + fps_deriv (inverse a) = 0" | |
| 1108 | unfolding power2_eq_square | |
| 36350 | 1109 | apply (simp add: field_simps) | 
| 29687 | 1110 | by (simp add: mult_assoc[symmetric]) | 
| 1111 | hence "inverse a ^ 2 * fps_deriv a + fps_deriv (inverse a) - fps_deriv a * inverse a ^ 2 = 0 - fps_deriv a * inverse a ^ 2" | |
| 1112 | by simp | |
| 36350 | 1113 | then show "fps_deriv (inverse a) = - fps_deriv a * inverse a ^ 2" by (simp add: field_simps) | 
| 29687 | 1114 | qed | 
| 1115 | ||
| 30488 | 1116 | lemma fps_inverse_mult: | 
| 29687 | 1117 |   fixes a::"('a :: field) fps"
 | 
| 1118 | shows "inverse (a * b) = inverse a * inverse b" | |
| 1119 | proof- | |
| 1120 |   {assume a0: "a$0 = 0" hence ab0: "(a*b)$0 = 0" by (simp add: fps_mult_nth)
 | |
| 1121 | from a0 ab0 have th: "inverse a = 0" "inverse (a*b) = 0" by simp_all | |
| 1122 | have ?thesis unfolding th by simp} | |
| 1123 | moreover | |
| 1124 |   {assume b0: "b$0 = 0" hence ab0: "(a*b)$0 = 0" by (simp add: fps_mult_nth)
 | |
| 1125 | from b0 ab0 have th: "inverse b = 0" "inverse (a*b) = 0" by simp_all | |
| 1126 | have ?thesis unfolding th by simp} | |
| 1127 | moreover | |
| 1128 |   {assume a0: "a$0 \<noteq> 0" and b0: "b$0 \<noteq> 0"
 | |
| 1129 | from a0 b0 have ab0:"(a*b) $ 0 \<noteq> 0" by (simp add: fps_mult_nth) | |
| 30488 | 1130 | from inverse_mult_eq_1[OF ab0] | 
| 29687 | 1131 | have "inverse (a*b) * (a*b) * inverse a * inverse b = 1 * inverse a * inverse b" by simp | 
| 1132 | then have "inverse (a*b) * (inverse a * a) * (inverse b * b) = inverse a * inverse b" | |
| 36350 | 1133 | by (simp add: field_simps) | 
| 29687 | 1134 | then have ?thesis using inverse_mult_eq_1[OF a0] inverse_mult_eq_1[OF b0] by simp} | 
| 1135 | ultimately show ?thesis by blast | |
| 1136 | qed | |
| 1137 | ||
| 30488 | 1138 | lemma fps_inverse_deriv': | 
| 29687 | 1139 |   fixes a:: "('a :: field) fps"
 | 
| 1140 | assumes a0: "a$0 \<noteq> 0" | |
| 1141 | shows "fps_deriv (inverse a) = - fps_deriv a / a ^ 2" | |
| 1142 | using fps_inverse_deriv[OF a0] | |
| 48757 | 1143 | unfolding power2_eq_square fps_divide_def fps_inverse_mult | 
| 1144 | by simp | |
| 29687 | 1145 | |
| 1146 | lemma inverse_mult_eq_1': assumes f0: "f$0 \<noteq> (0::'a::field)" | |
| 1147 | shows "f * inverse f= 1" | |
| 1148 | by (metis mult_commute inverse_mult_eq_1 f0) | |
| 1149 | ||
| 1150 | lemma fps_divide_deriv:   fixes a:: "('a :: field) fps"
 | |
| 1151 | assumes a0: "b$0 \<noteq> 0" | |
| 1152 | shows "fps_deriv (a / b) = (fps_deriv a * b - a * fps_deriv b) / b ^ 2" | |
| 1153 | using fps_inverse_deriv[OF a0] | |
| 48757 | 1154 | by (simp add: fps_divide_def field_simps | 
| 1155 | power2_eq_square fps_inverse_mult inverse_mult_eq_1'[OF a0]) | |
| 30488 | 1156 | |
| 29687 | 1157 | |
| 30488 | 1158 | lemma fps_inverse_gp': "inverse (Abs_fps(\<lambda>n. (1::'a::field))) | 
| 29687 | 1159 | = 1 - X" | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 1160 | by (simp add: fps_inverse_gp fps_eq_iff X_def) | 
| 29687 | 1161 | |
| 1162 | lemma fps_nth_deriv_X[simp]: "fps_nth_deriv n X = (if n = 0 then X else if n=1 then 1 else 0)" | |
| 1163 | by (cases "n", simp_all) | |
| 1164 | ||
| 1165 | ||
| 1166 | lemma fps_inverse_X_plus1: | |
| 31021 | 1167 |   "inverse (1 + X) = Abs_fps (\<lambda>n. (- (1::'a::{field})) ^ n)" (is "_ = ?r")
 | 
| 29687 | 1168 | proof- | 
| 1169 | have eq: "(1 + X) * ?r = 1" | |
| 1170 | unfolding minus_one_power_iff | |
| 36350 | 1171 | by (auto simp add: field_simps fps_eq_iff) | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 1172 | show ?thesis by (auto simp add: eq intro: fps_inverse_unique simp del: minus_one) | 
| 29687 | 1173 | qed | 
| 1174 | ||
| 30488 | 1175 | |
| 29906 | 1176 | subsection{* Integration *}
 | 
| 31273 | 1177 | |
| 1178 | definition | |
| 1179 | fps_integral :: "'a::field_char_0 fps \<Rightarrow> 'a \<Rightarrow> 'a fps" where | |
| 1180 | "fps_integral a a0 = Abs_fps (\<lambda>n. if n = 0 then a0 else (a$(n - 1) / of_nat n))" | |
| 29687 | 1181 | |
| 31273 | 1182 | lemma fps_deriv_fps_integral: "fps_deriv (fps_integral a a0) = a" | 
| 1183 | unfolding fps_integral_def fps_deriv_def | |
| 1184 | by (simp add: fps_eq_iff del: of_nat_Suc) | |
| 29687 | 1185 | |
| 31273 | 1186 | lemma fps_integral_linear: | 
| 1187 | "fps_integral (fps_const a * f + fps_const b * g) (a*a0 + b*b0) = | |
| 1188 | fps_const a * fps_integral f a0 + fps_const b * fps_integral g b0" | |
| 1189 | (is "?l = ?r") | |
| 29687 | 1190 | proof- | 
| 1191 | have "fps_deriv ?l = fps_deriv ?r" by (simp add: fps_deriv_fps_integral) | |
| 1192 | moreover have "?l$0 = ?r$0" by (simp add: fps_integral_def) | |
| 1193 | ultimately show ?thesis | |
| 1194 | unfolding fps_deriv_eq_iff by auto | |
| 1195 | qed | |
| 30488 | 1196 | |
| 29906 | 1197 | subsection {* Composition of FPSs *}
 | 
| 29687 | 1198 | definition fps_compose :: "('a::semiring_1) fps \<Rightarrow> 'a fps \<Rightarrow> 'a fps" (infixl "oo" 55) where
 | 
| 1199 |   fps_compose_def: "a oo b = Abs_fps (\<lambda>n. setsum (\<lambda>i. a$i * (b^i$n)) {0..n})"
 | |
| 1200 | ||
| 48757 | 1201 | lemma fps_compose_nth: "(a oo b)$n = setsum (\<lambda>i. a$i * (b^i$n)) {0..n}"
 | 
| 1202 | by (simp add: fps_compose_def) | |
| 29687 | 1203 | |
| 1204 | lemma fps_compose_X[simp]: "a oo X = (a :: ('a :: comm_ring_1) fps)"
 | |
| 29913 | 1205 | by (simp add: fps_ext fps_compose_def mult_delta_right setsum_delta') | 
| 30488 | 1206 | |
| 1207 | lemma fps_const_compose[simp]: | |
| 29687 | 1208 |   "fps_const (a::'a::{comm_ring_1}) oo b = fps_const (a)"
 | 
| 29913 | 1209 | by (simp add: fps_eq_iff fps_compose_nth mult_delta_left setsum_delta) | 
| 29687 | 1210 | |
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 1211 | lemma numeral_compose[simp]: "(numeral k::('a::{comm_ring_1}) fps) oo b = numeral k"
 | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 1212 | unfolding numeral_fps_const by simp | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 1213 | |
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 1214 | lemma neg_numeral_compose[simp]: "(neg_numeral k::('a::{comm_ring_1}) fps) oo b = neg_numeral k"
 | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 1215 | unfolding neg_numeral_fps_const by simp | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 1216 | |
| 29687 | 1217 | lemma X_fps_compose_startby0[simp]: "a$0 = 0 \<Longrightarrow> X oo a = (a :: ('a :: comm_ring_1) fps)"
 | 
| 29913 | 1218 | by (simp add: fps_eq_iff fps_compose_def mult_delta_left setsum_delta | 
| 1219 | power_Suc not_le) | |
| 29687 | 1220 | |
| 1221 | ||
| 29906 | 1222 | subsection {* Rules from Herbert Wilf's Generatingfunctionology*}
 | 
| 29687 | 1223 | |
| 29906 | 1224 | subsubsection {* Rule 1 *}
 | 
| 29687 | 1225 |   (* {a_{n+k}}_0^infty Corresponds to (f - setsum (\<lambda>i. a_i * x^i))/x^h, for h>0*)
 | 
| 1226 | ||
| 30488 | 1227 | lemma fps_power_mult_eq_shift: | 
| 30992 | 1228 |   "X^Suc k * Abs_fps (\<lambda>n. a (n + Suc k)) = Abs_fps a - setsum (\<lambda>i. fps_const (a i :: 'a:: comm_ring_1) * X^i) {0 .. k}" (is "?lhs = ?rhs")
 | 
| 29687 | 1229 | proof- | 
| 1230 |   {fix n:: nat
 | |
| 30488 | 1231 | have "?lhs $ n = (if n < Suc k then 0 else a n)" | 
| 29687 | 1232 | unfolding X_power_mult_nth by auto | 
| 1233 | also have "\<dots> = ?rhs $ n" | |
| 1234 | proof(induct k) | |
| 1235 | case 0 thus ?case by (simp add: fps_setsum_nth power_Suc) | |
| 1236 | next | |
| 1237 | case (Suc k) | |
| 1238 | note th = Suc.hyps[symmetric] | |
| 36350 | 1239 |       have "(Abs_fps a - setsum (\<lambda>i. fps_const (a i :: 'a) * X^i) {0 .. Suc k})$n = (Abs_fps a - setsum (\<lambda>i. fps_const (a i :: 'a) * X^i) {0 .. k} - fps_const (a (Suc k)) * X^ Suc k) $ n" by (simp add: field_simps)
 | 
| 29687 | 1240 | also have "\<dots> = (if n < Suc k then 0 else a n) - (fps_const (a (Suc k)) * X^ Suc k)$n" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1241 | using th | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1242 | unfolding fps_sub_nth by simp | 
| 29687 | 1243 | 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 | 1244 | unfolding X_power_mult_right_nth | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1245 | 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 | 1246 | apply (rule cong[of a a, OF refl]) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1247 | by arith | 
| 29687 | 1248 | finally show ?case by simp | 
| 1249 | qed | |
| 1250 | finally have "?lhs $ n = ?rhs $ n" .} | |
| 1251 | then show ?thesis by (simp add: fps_eq_iff) | |
| 1252 | qed | |
| 1253 | ||
| 29906 | 1254 | subsubsection{* Rule 2*}
 | 
| 29687 | 1255 | |
| 1256 | (* We can not reach the form of Wilf, but still near to it using rewrite rules*) | |
| 30488 | 1257 |   (* If f reprents {a_n} and P is a polynomial, then
 | 
| 29687 | 1258 |         P(xD) f represents {P(n) a_n}*)
 | 
| 1259 | ||
| 1260 | definition "XD = op * X o fps_deriv" | |
| 1261 | ||
| 1262 | lemma XD_add[simp]:"XD (a + b) = XD a + XD (b :: ('a::comm_ring_1) fps)"
 | |
| 36350 | 1263 | by (simp add: XD_def field_simps) | 
| 29687 | 1264 | |
| 1265 | lemma XD_mult_const[simp]:"XD (fps_const (c::'a::comm_ring_1) * a) = fps_const c * XD a" | |
| 36350 | 1266 | by (simp add: XD_def field_simps) | 
| 29687 | 1267 | |
| 1268 | lemma XD_linear[simp]: "XD (fps_const c * a + fps_const d * b) = fps_const c * XD a + fps_const d * XD (b :: ('a::comm_ring_1) fps)"
 | |
| 1269 | by simp | |
| 1270 | ||
| 30952 
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
 haftmann parents: 
30837diff
changeset | 1271 | lemma XDN_linear: | 
| 30971 | 1272 |   "(XD ^^ n) (fps_const c * a + fps_const d * b) = fps_const c * (XD ^^ n) a + fps_const d * (XD ^^ n) (b :: ('a::comm_ring_1) fps)"
 | 
| 48757 | 1273 | by (induct n) simp_all | 
| 29687 | 1274 | |
| 1275 | lemma fps_mult_X_deriv_shift: "X* fps_deriv a = Abs_fps (\<lambda>n. of_nat n* a$n)" by (simp add: fps_eq_iff) | |
| 1276 | ||
| 30994 | 1277 | |
| 30952 
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
 haftmann parents: 
30837diff
changeset | 1278 | lemma fps_mult_XD_shift: | 
| 31021 | 1279 |   "(XD ^^ k) (a:: ('a::{comm_ring_1}) fps) = Abs_fps (\<lambda>n. (of_nat n ^ k) * a$n)"
 | 
| 36350 | 1280 | by (induct k arbitrary: a) (simp_all add: power_Suc XD_def fps_eq_iff field_simps del: One_nat_def) | 
| 29687 | 1281 | |
| 29906 | 1282 | subsubsection{* Rule 3 is trivial and is given by @{text fps_times_def}*}
 | 
| 1283 | subsubsection{* Rule 5 --- summation and "division" by (1 - X)*}
 | |
| 29687 | 1284 | |
| 1285 | lemma fps_divide_X_minus1_setsum_lemma: | |
| 1286 |   "a = ((1::('a::comm_ring_1) fps) - X) * Abs_fps (\<lambda>n. setsum (\<lambda>i. a $ i) {0..n})"
 | |
| 1287 | proof- | |
| 1288 |   let ?X = "X::('a::comm_ring_1) fps"
 | |
| 1289 |   let ?sa = "Abs_fps (\<lambda>n. setsum (\<lambda>i. a $ i) {0..n})"
 | |
| 1290 | have th0: "\<And>i. (1 - (X::'a fps)) $ i = (if i = 0 then 1 else if i = 1 then - 1 else 0)" by simp | |
| 1291 |   {fix n:: nat
 | |
| 30488 | 1292 |     {assume "n=0" hence "a$n = ((1 - ?X) * ?sa) $ n"
 | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1293 | by (simp add: fps_mult_nth)} | 
| 29687 | 1294 | moreover | 
| 1295 |     {assume n0: "n \<noteq> 0"
 | |
| 1296 |       then have u: "{0} \<union> ({1} \<union> {2..n}) = {0..n}" "{1}\<union>{2..n} = {1..n}"
 | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1297 |         "{0..n - 1}\<union>{n} = {0..n}"
 | 
| 39302 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 nipkow parents: 
39198diff
changeset | 1298 | by (auto simp: set_eq_iff) | 
| 30488 | 1299 |       have d: "{0} \<inter> ({1} \<union> {2..n}) = {}" "{1} \<inter> {2..n} = {}"
 | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1300 |         "{0..n - 1}\<inter>{n} ={}" using n0 by simp_all
 | 
| 30488 | 1301 |       have f: "finite {0}" "finite {1}" "finite {2 .. n}"
 | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1302 |         "finite {0 .. n - 1}" "finite {n}" by simp_all
 | 
| 29687 | 1303 |     have "((1 - ?X) * ?sa) $ n = setsum (\<lambda>i. (1 - ?X)$ i * ?sa $ (n - i)) {0 .. n}"
 | 
| 1304 | by (simp add: fps_mult_nth) | |
| 1305 | also have "\<dots> = a$n" unfolding th0 | |
| 1306 | unfolding setsum_Un_disjoint[OF f(1) finite_UnI[OF f(2,3)] d(1), unfolded u(1)] | |
| 1307 | unfolding setsum_Un_disjoint[OF f(2) f(3) d(2)] | |
| 1308 | apply (simp) | |
| 1309 | unfolding setsum_Un_disjoint[OF f(4,5) d(3), unfolded u(3)] | |
| 1310 | by simp | |
| 1311 | finally have "a$n = ((1 - ?X) * ?sa) $ n" by simp} | |
| 1312 | ultimately have "a$n = ((1 - ?X) * ?sa) $ n" by blast} | |
| 30488 | 1313 | then show ?thesis | 
| 29687 | 1314 | unfolding fps_eq_iff by blast | 
| 1315 | qed | |
| 1316 | ||
| 1317 | lemma fps_divide_X_minus1_setsum: | |
| 1318 |   "a /((1::('a::field) fps) - X)  = Abs_fps (\<lambda>n. setsum (\<lambda>i. a $ i) {0..n})"
 | |
| 1319 | proof- | |
| 1320 |   let ?X = "1 - (X::('a::field) fps)"
 | |
| 1321 | have th0: "?X $ 0 \<noteq> 0" by simp | |
| 1322 |   have "a /?X = ?X *  Abs_fps (\<lambda>n\<Colon>nat. setsum (op $ a) {0..n}) * inverse ?X"
 | |
| 1323 | using fps_divide_X_minus1_setsum_lemma[of a, symmetric] th0 | |
| 1324 | by (simp add: fps_divide_def mult_assoc) | |
| 1325 |   also have "\<dots> = (inverse ?X * ?X) * Abs_fps (\<lambda>n\<Colon>nat. setsum (op $ a) {0..n}) "
 | |
| 1326 | by (simp add: mult_ac) | |
| 1327 | finally show ?thesis by (simp add: inverse_mult_eq_1[OF th0]) | |
| 1328 | qed | |
| 1329 | ||
| 30488 | 1330 | subsubsection{* Rule 4 in its more general form: generalizes Rule 3 for an arbitrary
 | 
| 29687 | 1331 | finite product of FPS, also the relvant instance of powers of a FPS*} | 
| 1332 | ||
| 46131 | 1333 | definition "natpermute n k = {l :: nat list. length l = k \<and> listsum l = n}"
 | 
| 29687 | 1334 | |
| 1335 | lemma natlist_trivial_1: "natpermute n 1 = {[n]}"
 | |
| 1336 | apply (auto simp add: natpermute_def) | |
| 1337 | apply (case_tac x, auto) | |
| 1338 | done | |
| 1339 | ||
| 1340 | lemma append_natpermute_less_eq: | |
| 46131 | 1341 | assumes h: "xs@ys \<in> natpermute n k" shows "listsum xs \<le> n" and "listsum ys \<le> n" | 
| 29687 | 1342 | proof- | 
| 46131 | 1343 |   {from h have "listsum (xs @ ys) = n" by (simp add: natpermute_def)
 | 
| 1344 | hence "listsum xs + listsum ys = n" by simp} | |
| 29687 | 1345 | note th = this | 
| 46131 | 1346 |   {from th show "listsum xs \<le> n" by simp}
 | 
| 1347 |   {from th show "listsum ys \<le> n" by simp}
 | |
| 29687 | 1348 | qed | 
| 1349 | ||
| 1350 | lemma natpermute_split: | |
| 1351 | assumes mn: "h \<le> k" | |
| 1352 |   shows "natpermute n k = (\<Union>m \<in>{0..n}. {l1 @ l2 |l1 l2. l1 \<in> natpermute m h \<and> l2 \<in> natpermute (n - m) (k - h)})" (is "?L = ?R" is "?L = (\<Union>m \<in>{0..n}. ?S m)")
 | |
| 1353 | proof- | |
| 30488 | 1354 |   {fix l assume l: "l \<in> ?R"
 | 
| 29687 | 1355 |     from l obtain m xs ys where h: "m \<in> {0..n}" and xs: "xs \<in> natpermute m h" and ys: "ys \<in> natpermute (n - m) (k - h)"  and leq: "l = xs@ys" by blast
 | 
| 46131 | 1356 | from xs have xs': "listsum xs = m" by (simp add: natpermute_def) | 
| 1357 | from ys have ys': "listsum ys = n - m" by (simp add: natpermute_def) | |
| 30488 | 1358 | have "l \<in> ?L" using leq xs ys h | 
| 46131 | 1359 | apply (clarsimp simp add: natpermute_def) | 
| 29687 | 1360 | unfolding xs' ys' | 
| 30488 | 1361 | using mn xs ys | 
| 48757 | 1362 | unfolding natpermute_def | 
| 1363 | apply simp | |
| 1364 | done | |
| 1365 | } | |
| 29687 | 1366 | moreover | 
| 1367 |   {fix l assume l: "l \<in> natpermute n k"
 | |
| 1368 | let ?xs = "take h l" | |
| 1369 | let ?ys = "drop h l" | |
| 46131 | 1370 | let ?m = "listsum ?xs" | 
| 1371 | from l have ls: "listsum (?xs @ ?ys) = n" by (simp add: natpermute_def) | |
| 30488 | 1372 | have xs: "?xs \<in> natpermute ?m h" using l mn by (simp add: natpermute_def) | 
| 46131 | 1373 | have l_take_drop: "listsum l = listsum (take h l @ drop h l)" by simp | 
| 1374 | then have ys: "?ys \<in> natpermute (n - ?m) (k - h)" using l mn ls | |
| 1375 | by (auto simp add: natpermute_def simp del: append_take_drop_id) | |
| 1376 |     from ls have m: "?m \<in> {0..n}" by (simp add: l_take_drop del: append_take_drop_id)
 | |
| 30488 | 1377 | from xs ys ls have "l \<in> ?R" | 
| 29687 | 1378 | apply auto | 
| 1379 | apply (rule bexI[where x = "?m"]) | |
| 1380 | apply (rule exI[where x = "?xs"]) | |
| 1381 | apply (rule exI[where x = "?ys"]) | |
| 46131 | 1382 | using ls l | 
| 1383 | apply (auto simp add: natpermute_def l_take_drop simp del: append_take_drop_id) | |
| 48757 | 1384 | apply simp | 
| 1385 | done | |
| 1386 | } | |
| 29687 | 1387 | ultimately show ?thesis by blast | 
| 1388 | qed | |
| 1389 | ||
| 1390 | lemma natpermute_0: "natpermute n 0 = (if n = 0 then {[]} else {})"
 | |
| 1391 | by (auto simp add: natpermute_def) | |
| 1392 | lemma natpermute_0'[simp]: "natpermute 0 k = (if k = 0 then {[]} else {replicate k 0})"
 | |
| 1393 | apply (auto simp add: set_replicate_conv_if natpermute_def) | |
| 1394 | apply (rule nth_equalityI) | |
| 48757 | 1395 | apply simp_all | 
| 1396 | done | |
| 29687 | 1397 | |
| 1398 | lemma natpermute_finite: "finite (natpermute n k)" | |
| 1399 | proof(induct k arbitrary: n) | |
| 30488 | 1400 | case 0 thus ?case | 
| 29687 | 1401 | apply (subst natpermute_split[of 0 0, simplified]) | 
| 1402 | by (simp add: natpermute_0) | |
| 1403 | next | |
| 1404 | case (Suc k) | |
| 1405 | then show ?case unfolding natpermute_split[of k "Suc k", simplified] | |
| 1406 | apply - | |
| 1407 | apply (rule finite_UN_I) | |
| 1408 | apply simp | |
| 1409 | unfolding One_nat_def[symmetric] natlist_trivial_1 | |
| 1410 | apply simp | |
| 1411 | done | |
| 1412 | qed | |
| 1413 | ||
| 1414 | lemma natpermute_contain_maximal: | |
| 1415 |   "{xs \<in> natpermute n (k+1). n \<in> set xs} = UNION {0 .. k} (\<lambda>i. {(replicate (k+1) 0) [i:=n]})"
 | |
| 1416 | (is "?A = ?B") | |
| 1417 | proof- | |
| 1418 |   {fix xs assume H: "xs \<in> natpermute n (k+1)" and n: "n \<in> set xs"
 | |
| 1419 |     from n obtain i where i: "i \<in> {0.. k}" "xs!i = n" using H
 | |
| 30488 | 1420 | unfolding in_set_conv_nth by (auto simp add: less_Suc_eq_le natpermute_def) | 
| 29687 | 1421 |     have eqs: "({0..k} - {i}) \<union> {i} = {0..k}" using i by auto
 | 
| 1422 |     have f: "finite({0..k} - {i})" "finite {i}" by auto
 | |
| 1423 |     have d: "({0..k} - {i}) \<inter> {i} = {}" using i by auto
 | |
| 1424 |     from H have "n = setsum (nth xs) {0..k}" apply (simp add: natpermute_def)
 | |
| 46131 | 1425 | by (auto simp add: atLeastLessThanSuc_atLeastAtMost listsum_setsum_nth) | 
| 29687 | 1426 |     also have "\<dots> = n + setsum (nth xs) ({0..k} - {i})"
 | 
| 1427 | unfolding setsum_Un_disjoint[OF f d, unfolded eqs] using i by simp | |
| 1428 |     finally have zxs: "\<forall> j\<in> {0..k} - {i}. xs!j = 0" by auto
 | |
| 1429 | from H have xsl: "length xs = k+1" by (simp add: natpermute_def) | |
| 1430 | from i have i': "i < length (replicate (k+1) 0)" "i < k+1" | |
| 1431 | unfolding length_replicate by arith+ | |
| 1432 | have "xs = replicate (k+1) 0 [i := n]" | |
| 1433 | apply (rule nth_equalityI) | |
| 1434 | unfolding xsl length_list_update length_replicate | |
| 1435 | apply simp | |
| 1436 | apply clarify | |
| 1437 | unfolding nth_list_update[OF i'(1)] | |
| 1438 | using i zxs | |
| 1439 | by (case_tac "ia=i", auto simp del: replicate.simps) | |
| 48757 | 1440 | then have "xs \<in> ?B" using i by blast | 
| 1441 | } | |
| 29687 | 1442 | moreover | 
| 1443 |   {fix i assume i: "i \<in> {0..k}"
 | |
| 1444 | let ?xs = "replicate (k+1) 0 [i:=n]" | |
| 1445 | have nxs: "n \<in> set ?xs" | |
| 1446 | apply (rule set_update_memI) using i by simp | |
| 1447 | have xsl: "length ?xs = k+1" by (simp only: length_replicate length_list_update) | |
| 46131 | 1448 |     have "listsum ?xs = setsum (nth ?xs) {0..<k+1}"
 | 
| 1449 | unfolding listsum_setsum_nth xsl .. | |
| 29687 | 1450 |     also have "\<dots> = setsum (\<lambda>j. if j = i then n else 0) {0..< k+1}"
 | 
| 1451 | apply (rule setsum_cong2) by (simp del: replicate.simps) | |
| 1452 | also have "\<dots> = n" using i by (simp add: setsum_delta) | |
| 30488 | 1453 | finally | 
| 44174 
d1d79f0e1ea6
make more HOL theories work with separate set type
 huffman parents: 
41959diff
changeset | 1454 | have "?xs \<in> natpermute n (k+1)" using xsl unfolding natpermute_def mem_Collect_eq | 
| 29687 | 1455 | by blast | 
| 48757 | 1456 | then have "?xs \<in> ?A" using nxs by blast | 
| 1457 | } | |
| 29687 | 1458 | ultimately show ?thesis by auto | 
| 1459 | qed | |
| 1460 | ||
| 30488 | 1461 | (* The general form *) | 
| 29687 | 1462 | lemma fps_setprod_nth: | 
| 1463 |   fixes m :: nat and a :: "nat \<Rightarrow> ('a::comm_ring_1) fps"
 | |
| 1464 |   shows "(setprod a {0 .. m})$n = setsum (\<lambda>v. setprod (\<lambda>j. (a j) $ (v!j)) {0..m}) (natpermute n (m+1))"
 | |
| 1465 | (is "?P m n") | |
| 1466 | proof(induct m arbitrary: n rule: nat_less_induct) | |
| 1467 | fix m n assume H: "\<forall>m' < m. \<forall>n. ?P m' n" | |
| 1468 |   {assume m0: "m = 0"
 | |
| 1469 | hence "?P m n" apply simp | |
| 1470 | unfolding natlist_trivial_1[where n = n, unfolded One_nat_def] by simp} | |
| 1471 | moreover | |
| 1472 |   {fix k assume k: "m = Suc k"
 | |
| 1473 | have km: "k < m" using k by arith | |
| 39302 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 nipkow parents: 
39198diff
changeset | 1474 |     have u0: "{0 .. k} \<union> {m} = {0..m}" using k apply (simp add: set_eq_iff) by presburger
 | 
| 29687 | 1475 |     have f0: "finite {0 .. k}" "finite {m}" by auto
 | 
| 1476 |     have d0: "{0 .. k} \<inter> {m} = {}" using k by auto
 | |
| 1477 |     have "(setprod a {0 .. m}) $ n = (setprod a {0 .. k} * a m) $ n"
 | |
| 1478 | unfolding setprod_Un_disjoint[OF f0 d0, unfolded u0] by simp | |
| 1479 |     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))"
 | |
| 1480 | unfolding fps_mult_nth H[rule_format, OF km] .. | |
| 1481 |     also have "\<dots> = (\<Sum>v\<in>natpermute n (m + 1). \<Prod>j\<in>{0..m}. a j $ v ! j)"
 | |
| 1482 | apply (simp add: k) | |
| 48757 | 1483 | unfolding natpermute_split[of m "m + 1", simplified, of n, | 
| 1484 | unfolded natlist_trivial_1[unfolded One_nat_def] k] | |
| 29687 | 1485 | apply (subst setsum_UN_disjoint) | 
| 30488 | 1486 | apply simp | 
| 29687 | 1487 | apply simp | 
| 1488 | unfolding image_Collect[symmetric] | |
| 1489 | apply clarsimp | |
| 1490 | apply (rule finite_imageI) | |
| 1491 | 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 | 1492 | apply (clarsimp simp add: set_eq_iff) | 
| 29687 | 1493 | apply auto | 
| 1494 | apply (rule setsum_cong2) | |
| 1495 | unfolding setsum_left_distrib | |
| 1496 | apply (rule sym) | |
| 1497 | apply (rule_tac f="\<lambda>xs. xs @[n - x]" in setsum_reindex_cong) | |
| 1498 | apply (simp add: inj_on_def) | |
| 1499 | apply auto | |
| 1500 | unfolding setprod_Un_disjoint[OF f0 d0, unfolded u0, unfolded k] | |
| 1501 | apply (clarsimp simp add: natpermute_def nth_append) | |
| 1502 | done | |
| 48757 | 1503 | finally have "?P m n" . | 
| 1504 | } | |
| 1505 | ultimately show "?P m n " by (cases m) auto | |
| 29687 | 1506 | qed | 
| 1507 | ||
| 1508 | text{* The special form for powers *}
 | |
| 1509 | lemma fps_power_nth_Suc: | |
| 1510 |   fixes m :: nat and a :: "('a::comm_ring_1) fps"
 | |
| 1511 |   shows "(a ^ Suc m)$n = setsum (\<lambda>v. setprod (\<lambda>j. a $ (v!j)) {0..m}) (natpermute n (m+1))"
 | |
| 1512 | proof- | |
| 46757 | 1513 |   have th0: "a^Suc m = setprod (\<lambda>i. a) {0..m}" by (simp add: setprod_constant)
 | 
| 29687 | 1514 | show ?thesis unfolding th0 fps_setprod_nth .. | 
| 1515 | qed | |
| 1516 | lemma fps_power_nth: | |
| 1517 |   fixes m :: nat and a :: "('a::comm_ring_1) fps"
 | |
| 1518 |   shows "(a ^m)$n = (if m=0 then 1$n else setsum (\<lambda>v. setprod (\<lambda>j. a $ (v!j)) {0..m - 1}) (natpermute n m))"
 | |
| 30273 
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
 huffman parents: 
29915diff
changeset | 1519 | by (cases m, simp_all add: fps_power_nth_Suc del: power_Suc) | 
| 29687 | 1520 | |
| 30488 | 1521 | lemma fps_nth_power_0: | 
| 31021 | 1522 |   fixes m :: nat and a :: "('a::{comm_ring_1}) fps"
 | 
| 29687 | 1523 | shows "(a ^m)$0 = (a$0) ^ m" | 
| 1524 | proof- | |
| 1525 |   {assume "m=0" hence ?thesis by simp}
 | |
| 1526 | moreover | |
| 1527 |   {fix n assume m: "m = Suc n"
 | |
| 1528 |     have c: "m = card {0..n}" using m by simp
 | |
| 1529 |    have "(a ^m)$0 = setprod (\<lambda>i. a$0) {0..n}"
 | |
| 30837 
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
 nipkow parents: 
30747diff
changeset | 1530 | by (simp add: m fps_power_nth del: replicate.simps power_Suc) | 
| 29687 | 1531 | also have "\<dots> = (a$0) ^ m" | 
| 1532 | unfolding c by (rule setprod_constant, simp) | |
| 1533 | finally have ?thesis .} | |
| 1534 | ultimately show ?thesis by (cases m, auto) | |
| 1535 | qed | |
| 1536 | ||
| 30488 | 1537 | lemma fps_compose_inj_right: | 
| 31021 | 1538 |   assumes a0: "a$0 = (0::'a::{idom})"
 | 
| 29687 | 1539 | and a1: "a$1 \<noteq> 0" | 
| 1540 | shows "(b oo a = c oo a) \<longleftrightarrow> b = c" (is "?lhs \<longleftrightarrow>?rhs") | |
| 1541 | proof- | |
| 1542 |   {assume ?rhs then have "?lhs" by simp}
 | |
| 1543 | moreover | |
| 1544 |   {assume h: ?lhs
 | |
| 30488 | 1545 |     {fix n have "b$n = c$n"
 | 
| 29687 | 1546 | proof(induct n rule: nat_less_induct) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1547 | fix n assume H: "\<forall>m<n. b$m = c$m" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1548 |         {assume n0: "n=0"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1549 | from h have "(b oo a)$n = (c oo a)$n" by simp | 
| 48757 | 1550 | hence "b$n = c$n" using n0 by (simp add: fps_compose_nth) | 
| 1551 | } | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1552 | moreover | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1553 |         {fix n1 assume n1: "n = Suc n1"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1554 |           have f: "finite {0 .. n1}" "finite {n}" by simp_all
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1555 |           have eq: "{0 .. n1} \<union> {n} = {0 .. n}" using n1 by auto
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1556 |           have d: "{0 .. n1} \<inter> {n} = {}" using n1 by auto
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1557 | have seq: "(\<Sum>i = 0..n1. b $ i * a ^ i $ n) = (\<Sum>i = 0..n1. c $ i * a ^ i $ n)" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1558 | apply (rule setsum_cong2) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1559 | using H n1 by auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1560 | have th0: "(b oo a) $n = (\<Sum>i = 0..n1. c $ i * a ^ i $ n) + b$n * (a$1)^n" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1561 | unfolding fps_compose_nth setsum_Un_disjoint[OF f d, unfolded eq] seq | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1562 | using startsby_zero_power_nth_same[OF a0] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1563 | by simp | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1564 | have th1: "(c oo a) $n = (\<Sum>i = 0..n1. c $ i * a ^ i $ n) + c$n * (a$1)^n" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1565 | unfolding fps_compose_nth setsum_Un_disjoint[OF f d, unfolded eq] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1566 | using startsby_zero_power_nth_same[OF a0] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1567 | by simp | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1568 | from h[unfolded fps_eq_iff, rule_format, of n] th0 th1 a1 | 
| 48757 | 1569 | have "b$n = c$n" by auto | 
| 1570 | } | |
| 1571 | ultimately show "b$n = c$n" by (cases n) auto | |
| 29687 | 1572 | qed} | 
| 48757 | 1573 | then have ?rhs by (simp add: fps_eq_iff) | 
| 1574 | } | |
| 29687 | 1575 | ultimately show ?thesis by blast | 
| 1576 | qed | |
| 1577 | ||
| 1578 | ||
| 29906 | 1579 | subsection {* Radicals *}
 | 
| 29687 | 1580 | |
| 1581 | declare setprod_cong[fundef_cong] | |
| 31021 | 1582 | function radical :: "(nat \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> nat \<Rightarrow> ('a::{field}) fps \<Rightarrow> nat \<Rightarrow> 'a" where
 | 
| 29687 | 1583 | "radical r 0 a 0 = 1" | 
| 1584 | | "radical r 0 a (Suc n) = 0" | |
| 1585 | | "radical r (Suc k) a 0 = r (Suc k) (a$0)" | |
| 48757 | 1586 | | "radical r (Suc k) a (Suc n) = | 
| 1587 |     (a$ Suc n - setsum (\<lambda>xs. setprod (\<lambda>j. radical r (Suc k) a (xs ! j)) {0..k})
 | |
| 1588 |       {xs. xs \<in> natpermute (Suc n) (Suc k) \<and> Suc n \<notin> set xs}) /
 | |
| 1589 | (of_nat (Suc k) * (radical r (Suc k) a 0)^k)" | |
| 29687 | 1590 | by pat_completeness auto | 
| 1591 | ||
| 1592 | termination radical | |
| 1593 | proof | |
| 1594 | let ?R = "measure (\<lambda>(r, k, a, n). n)" | |
| 1595 |   {
 | |
| 1596 | show "wf ?R" by auto} | |
| 1597 |   {fix r k a n xs i
 | |
| 1598 |     assume xs: "xs \<in> {xs \<in> natpermute (Suc n) (Suc k). Suc n \<notin> set xs}" and i: "i \<in> {0..k}"
 | |
| 1599 |     {assume c: "Suc n \<le> xs ! i"
 | |
| 1600 | from xs i have "xs !i \<noteq> Suc n" by (auto simp add: in_set_conv_nth natpermute_def) | |
| 1601 | with c have c': "Suc n < xs!i" by arith | |
| 1602 |       have fths: "finite {0 ..< i}" "finite {i}" "finite {i+1..<Suc k}" by simp_all
 | |
| 1603 |       have d: "{0 ..< i} \<inter> ({i} \<union> {i+1 ..< Suc k}) = {}" "{i} \<inter> {i+1..< Suc k} = {}" by auto
 | |
| 1604 |       have eqs: "{0..<Suc k} = {0 ..< i} \<union> ({i} \<union> {i+1 ..< Suc k})" using i by auto
 | |
| 46131 | 1605 | from xs have "Suc n = listsum xs" by (simp add: natpermute_def) | 
| 1606 |       also have "\<dots> = setsum (nth xs) {0..<Suc k}" using xs
 | |
| 1607 | by (simp add: natpermute_def listsum_setsum_nth) | |
| 29687 | 1608 |       also have "\<dots> = xs!i + setsum (nth xs) {0..<i} + setsum (nth xs) {i+1..<Suc k}"
 | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1609 | unfolding eqs setsum_Un_disjoint[OF fths(1) finite_UnI[OF fths(2,3)] d(1)] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1610 | unfolding setsum_Un_disjoint[OF fths(2) fths(3) d(2)] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1611 | by simp | 
| 29687 | 1612 | finally have False using c' by simp} | 
| 30488 | 1613 | then show "((r,Suc k,a,xs!i), r, Suc k, a, Suc n) \<in> ?R" | 
| 29687 | 1614 | apply auto by (metis not_less)} | 
| 30488 | 1615 |   {fix r k a n
 | 
| 29687 | 1616 | show "((r,Suc k, a, 0),r, Suc k, a, Suc n) \<in> ?R" by simp} | 
| 1617 | qed | |
| 1618 | ||
| 1619 | definition "fps_radical r n a = Abs_fps (radical r n a)" | |
| 1620 | ||
| 1621 | lemma fps_radical0[simp]: "fps_radical r 0 a = 1" | |
| 1622 | apply (auto simp add: fps_eq_iff fps_radical_def) by (case_tac n, auto) | |
| 1623 | ||
| 1624 | lemma fps_radical_nth_0[simp]: "fps_radical r n a $ 0 = (if n=0 then 1 else r n (a$0))" | |
| 1625 | by (cases n, simp_all add: fps_radical_def) | |
| 1626 | ||
| 30488 | 1627 | lemma fps_radical_power_nth[simp]: | 
| 29687 | 1628 | assumes r: "(r k (a$0)) ^ k = a$0" | 
| 1629 | shows "fps_radical r k a ^ k $ 0 = (if k = 0 then 1 else a$0)" | |
| 1630 | proof- | |
| 1631 |   {assume "k=0" hence ?thesis by simp }
 | |
| 1632 | moreover | |
| 30488 | 1633 |   {fix h assume h: "k = Suc h"
 | 
| 29687 | 1634 |     have eq1: "fps_radical r k a ^ k $ 0 = (\<Prod>j\<in>{0..h}. fps_radical r k a $ (replicate k 0) ! j)"
 | 
| 1635 | unfolding fps_power_nth h by simp | |
| 1636 |     also have "\<dots> = (\<Prod>j\<in>{0..h}. r k (a$0))"
 | |
| 1637 | apply (rule setprod_cong) | |
| 1638 | apply simp | |
| 1639 | using h | |
| 1640 | apply (subgoal_tac "replicate k (0::nat) ! x = 0") | |
| 1641 | by (auto intro: nth_replicate simp del: replicate.simps) | |
| 1642 | also have "\<dots> = a$0" | |
| 46757 | 1643 | using r by (simp add: h setprod_constant) | 
| 29687 | 1644 | finally have ?thesis using h by simp} | 
| 1645 | ultimately show ?thesis by (cases k, auto) | |
| 30488 | 1646 | qed | 
| 29687 | 1647 | |
| 30488 | 1648 | lemma natpermute_max_card: assumes n0: "n\<noteq>0" | 
| 29687 | 1649 |   shows "card {xs \<in> natpermute n (k+1). n \<in> set xs} = k+1"
 | 
| 1650 | unfolding natpermute_contain_maximal | |
| 1651 | proof- | |
| 1652 |   let ?A= "\<lambda>i. {replicate (k + 1) 0[i := n]}"
 | |
| 1653 |   let ?K = "{0 ..k}"
 | |
| 1654 | have fK: "finite ?K" by simp | |
| 1655 | have fAK: "\<forall>i\<in>?K. finite (?A i)" by auto | |
| 48757 | 1656 | have d: "\<forall>i\<in> ?K. \<forall>j\<in> ?K. i \<noteq> j \<longrightarrow> | 
| 1657 |     {replicate (k + 1) 0[i := n]} \<inter> {replicate (k + 1) 0[j := n]} = {}"
 | |
| 29687 | 1658 | proof(clarify) | 
| 1659 | fix i j assume i: "i \<in> ?K" and j: "j\<in> ?K" and ij: "i\<noteq>j" | |
| 1660 |     {assume eq: "replicate (k+1) 0 [i:=n] = replicate (k+1) 0 [j:= n]"
 | |
| 1661 | have "(replicate (k+1) 0 [i:=n] ! i) = n" using i by (simp del: replicate.simps) | |
| 1662 | moreover | |
| 1663 | have "(replicate (k+1) 0 [j:=n] ! i) = 0" using i ij by (simp del: replicate.simps) | |
| 1664 | ultimately have False using eq n0 by (simp del: replicate.simps)} | |
| 1665 |     then show "{replicate (k + 1) 0[i := n]} \<inter> {replicate (k + 1) 0[j := n]} = {}"
 | |
| 1666 | by auto | |
| 1667 | qed | |
| 30488 | 1668 | from card_UN_disjoint[OF fK fAK d] | 
| 29687 | 1669 |   show "card (\<Union>i\<in>{0..k}. {replicate (k + 1) 0[i := n]}) = k+1" by simp
 | 
| 1670 | qed | |
| 30488 | 1671 | |
| 1672 | lemma power_radical: | |
| 31273 | 1673 | fixes a:: "'a::field_char_0 fps" | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1674 | assumes a0: "a$0 \<noteq> 0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1675 | shows "(r (Suc k) (a$0)) ^ Suc k = a$0 \<longleftrightarrow> (fps_radical r (Suc k) a) ^ (Suc k) = a" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1676 | proof- | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1677 | let ?r = "fps_radical r (Suc k) a" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1678 |   {assume r0: "(r (Suc k) (a$0)) ^ Suc k = a$0"
 | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1679 | from a0 r0 have r00: "r (Suc k) (a$0) \<noteq> 0" by auto | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1680 |     {fix z have "?r ^ Suc k $ z = a$z"
 | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1681 | proof(induct z rule: nat_less_induct) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1682 | fix n assume H: "\<forall>m<n. ?r ^ Suc k $ m = a$m" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1683 |         {assume "n = 0" hence "?r ^ Suc k $ n = a $n"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1684 | using fps_radical_power_nth[of r "Suc k" a, OF r0] by simp} | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1685 | moreover | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1686 |         {fix n1 assume n1: "n = Suc n1"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1687 | 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 | 1688 | let ?Pnk = "natpermute n (k + 1)" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1689 |           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 | 1690 |           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 | 1691 | have eq: "?Pnkn \<union> ?Pnknn = ?Pnk" by blast | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1692 |           have d: "?Pnkn \<inter> ?Pnknn = {}" by blast
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1693 | have f: "finite ?Pnkn" "finite ?Pnknn" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1694 | using finite_Un[of ?Pnkn ?Pnknn, unfolded eq] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1695 | by (metis natpermute_finite)+ | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1696 |           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 | 1697 | have "setsum ?f ?Pnkn = setsum (\<lambda>v. ?r $ n * r (Suc k) (a $ 0) ^ k) ?Pnkn" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1698 | proof(rule setsum_cong2) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1699 |             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 | 1700 |             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 | 1701 |           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 | 1702 | unfolding natpermute_contain_maximal by auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1703 |           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))"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1704 | apply (rule setprod_cong, simp) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1705 | using i r0 by (simp del: replicate.simps) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1706 | also have "\<dots> = (fps_radical r (Suc k) a $ n) * r (Suc k) (a$0) ^ k" | 
| 46757 | 1707 | using i r0 by (simp add: setprod_gen_delta) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1708 | finally show ?ths . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1709 | qed | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1710 | then have "setsum ?f ?Pnkn = of_nat (k+1) * ?r $ n * r (Suc k) (a $ 0) ^ k" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1711 | by (simp add: natpermute_max_card[OF nz, simplified]) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1712 | also have "\<dots> = a$n - setsum ?f ?Pnknn" | 
| 36350 | 1713 | unfolding n1 using r00 a0 by (simp add: field_simps fps_radical_def del: of_nat_Suc) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1714 | finally have fn: "setsum ?f ?Pnkn = a$n - setsum ?f ?Pnknn" . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1715 | have "(?r ^ Suc k)$n = setsum ?f ?Pnkn + setsum ?f ?Pnknn" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1716 | unfolding fps_power_nth_Suc setsum_Un_disjoint[OF f d, unfolded eq] .. | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1717 | 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 | 1718 | finally have "?r ^ Suc k $ n = a $n" .} | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1719 | ultimately show "?r ^ Suc k $ n = a $n" by (cases n, auto) | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1720 | qed } | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1721 | then have ?thesis using r0 by (simp add: fps_eq_iff)} | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1722 | moreover | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1723 | { assume h: "(fps_radical r (Suc k) a) ^ (Suc k) = a"
 | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1724 | hence "((fps_radical r (Suc k) a) ^ (Suc k))$0 = a$0" by simp | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1725 | then have "(r (Suc k) (a$0)) ^ Suc k = a$0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1726 | unfolding fps_power_nth_Suc | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1727 | by (simp add: setprod_constant del: replicate.simps)} | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1728 | ultimately show ?thesis by blast | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1729 | qed | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1730 | |
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1731 | (* | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1732 | lemma power_radical: | 
| 31273 | 1733 | fixes a:: "'a::field_char_0 fps" | 
| 29687 | 1734 | assumes r0: "(r (Suc k) (a$0)) ^ Suc k = a$0" and a0: "a$0 \<noteq> 0" | 
| 30488 | 1735 | shows "(fps_radical r (Suc k) a) ^ (Suc k) = a" | 
| 29687 | 1736 | proof- | 
| 1737 | let ?r = "fps_radical r (Suc k) a" | |
| 1738 | from a0 r0 have r00: "r (Suc k) (a$0) \<noteq> 0" by auto | |
| 1739 |   {fix z have "?r ^ Suc k $ z = a$z"
 | |
| 1740 | proof(induct z rule: nat_less_induct) | |
| 1741 | fix n assume H: "\<forall>m<n. ?r ^ Suc k $ m = a$m" | |
| 1742 |       {assume "n = 0" hence "?r ^ Suc k $ n = a $n"
 | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1743 | using fps_radical_power_nth[of r "Suc k" a, OF r0] by simp} | 
| 29687 | 1744 | moreover | 
| 1745 |       {fix n1 assume n1: "n = Suc n1"
 | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1746 |         have fK: "finite {0..k}" by simp
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1747 | 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 | 1748 | let ?Pnk = "natpermute n (k + 1)" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1749 |         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 | 1750 |         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 | 1751 | have eq: "?Pnkn \<union> ?Pnknn = ?Pnk" by blast | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1752 |         have d: "?Pnkn \<inter> ?Pnknn = {}" by blast
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1753 | have f: "finite ?Pnkn" "finite ?Pnknn" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1754 | using finite_Un[of ?Pnkn ?Pnknn, unfolded eq] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1755 | by (metis natpermute_finite)+ | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1756 |         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 | 1757 | have "setsum ?f ?Pnkn = setsum (\<lambda>v. ?r $ n * r (Suc k) (a $ 0) ^ k) ?Pnkn" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1758 | proof(rule setsum_cong2) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1759 |           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 | 1760 |           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 | 1761 |           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 | 1762 | unfolding natpermute_contain_maximal by auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1763 |           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))"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1764 | apply (rule setprod_cong, simp) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1765 | using i r0 by (simp del: replicate.simps) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1766 | also have "\<dots> = (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 | 1767 | unfolding setprod_gen_delta[OF fK] using i r0 by simp | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1768 | finally show ?ths . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1769 | qed | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1770 | then have "setsum ?f ?Pnkn = of_nat (k+1) * ?r $ n * r (Suc k) (a $ 0) ^ k" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1771 | by (simp add: natpermute_max_card[OF nz, simplified]) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1772 | also have "\<dots> = a$n - setsum ?f ?Pnknn" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1773 | unfolding n1 using r00 a0 by (simp add: field_simps fps_radical_def del: of_nat_Suc ) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1774 | finally have fn: "setsum ?f ?Pnkn = a$n - setsum ?f ?Pnknn" . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1775 | have "(?r ^ Suc k)$n = setsum ?f ?Pnkn + setsum ?f ?Pnknn" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1776 | unfolding fps_power_nth_Suc setsum_Un_disjoint[OF f d, unfolded eq] .. | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1777 | 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 | 1778 | finally have "?r ^ Suc k $ n = a $n" .} | 
| 29687 | 1779 | ultimately show "?r ^ Suc k $ n = a $n" by (cases n, auto) | 
| 1780 | qed } | |
| 1781 | then show ?thesis by (simp add: fps_eq_iff) | |
| 1782 | qed | |
| 1783 | ||
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1784 | *) | 
| 29687 | 1785 | lemma eq_divide_imp': assumes c0: "(c::'a::field) ~= 0" and eq: "a * c = b" | 
| 30488 | 1786 | shows "a = b / c" | 
| 29687 | 1787 | proof- | 
| 1788 | from eq have "a * c * inverse c = b * inverse c" by simp | |
| 36350 | 1789 | hence "a * (inverse c * c) = b/c" by (simp only: field_simps divide_inverse) | 
| 29687 | 1790 | then show "a = b/c" unfolding field_inverse[OF c0] by simp | 
| 1791 | qed | |
| 1792 | ||
| 30488 | 1793 | lemma radical_unique: | 
| 1794 | assumes r0: "(r (Suc k) (b$0)) ^ Suc k = b$0" | |
| 31273 | 1795 | and a0: "r (Suc k) (b$0 ::'a::field_char_0) = a$0" and b0: "b$0 \<noteq> 0" | 
| 29687 | 1796 | shows "a^(Suc k) = b \<longleftrightarrow> a = fps_radical r (Suc k) b" | 
| 1797 | proof- | |
| 1798 | let ?r = "fps_radical r (Suc k) b" | |
| 1799 | have r00: "r (Suc k) (b$0) \<noteq> 0" using b0 r0 by auto | |
| 1800 |   {assume H: "a = ?r"
 | |
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1801 | from H have "a^Suc k = b" using power_radical[OF b0, of r k, unfolded r0] by simp} | 
| 29687 | 1802 | moreover | 
| 1803 |   {assume H: "a^Suc k = b"
 | |
| 1804 |     have ceq: "card {0..k} = Suc k" by simp
 | |
| 1805 | from a0 have a0r0: "a$0 = ?r$0" by simp | |
| 1806 |     {fix n have "a $ n = ?r $ n"
 | |
| 1807 | proof(induct n rule: nat_less_induct) | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1808 | fix n assume h: "\<forall>m<n. a$m = ?r $m" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1809 |         {assume "n = 0" hence "a$n = ?r $n" using a0 by simp }
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1810 | moreover | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1811 |         {fix n1 assume n1: "n = Suc n1"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1812 |           have fK: "finite {0..k}" by simp
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1813 | 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 | 1814 | let ?Pnk = "natpermute n (Suc k)" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1815 |         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 | 1816 |         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 | 1817 | have eq: "?Pnkn \<union> ?Pnknn = ?Pnk" by blast | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1818 |         have d: "?Pnkn \<inter> ?Pnknn = {}" by blast
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1819 | have f: "finite ?Pnkn" "finite ?Pnknn" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1820 | using finite_Un[of ?Pnkn ?Pnknn, unfolded eq] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1821 | by (metis natpermute_finite)+ | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1822 |         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 | 1823 |         let ?g = "\<lambda>v. \<Prod>j\<in>{0..k}. a $ v ! j"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1824 | have "setsum ?g ?Pnkn = setsum (\<lambda>v. a $ n * (?r$0)^k) ?Pnkn" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1825 | proof(rule setsum_cong2) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1826 |           fix v assume v: "v \<in> {xs \<in> natpermute n (Suc k). n \<in> set xs}"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1827 |           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 | 1828 |           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 | 1829 | unfolding Suc_eq_plus1 natpermute_contain_maximal by (auto simp del: replicate.simps) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1830 |           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))"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1831 | apply (rule setprod_cong, simp) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1832 | using i a0 by (simp del: replicate.simps) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1833 | also have "\<dots> = a $ n * (?r $ 0)^k" | 
| 46757 | 1834 | using i by (simp add: setprod_gen_delta) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1835 | finally show ?ths . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1836 | qed | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1837 | then have th0: "setsum ?g ?Pnkn = of_nat (k+1) * a $ n * (?r $ 0)^k" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1838 | by (simp add: natpermute_max_card[OF nz, simplified]) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1839 | have th1: "setsum ?g ?Pnknn = setsum ?f ?Pnknn" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1840 | proof (rule setsum_cong2, rule setprod_cong, simp) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1841 |           fix xs i assume xs: "xs \<in> ?Pnknn" and i: "i \<in> {0..k}"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1842 |           {assume c: "n \<le> xs ! i"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1843 | from xs i have "xs !i \<noteq> n" by (auto simp add: in_set_conv_nth natpermute_def) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1844 | with c have c': "n < xs!i" by arith | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1845 |             have fths: "finite {0 ..< i}" "finite {i}" "finite {i+1..<Suc k}" by simp_all
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1846 |             have d: "{0 ..< i} \<inter> ({i} \<union> {i+1 ..< Suc k}) = {}" "{i} \<inter> {i+1..< Suc k} = {}" by auto
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1847 |             have eqs: "{0..<Suc k} = {0 ..< i} \<union> ({i} \<union> {i+1 ..< Suc k})" using i by auto
 | 
| 46131 | 1848 | from xs have "n = listsum xs" by (simp add: natpermute_def) | 
| 1849 |             also have "\<dots> = setsum (nth xs) {0..<Suc k}" using xs
 | |
| 1850 | by (simp add: natpermute_def listsum_setsum_nth) | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1851 |             also have "\<dots> = xs!i + setsum (nth xs) {0..<i} + setsum (nth xs) {i+1..<Suc k}"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1852 | unfolding eqs setsum_Un_disjoint[OF fths(1) finite_UnI[OF fths(2,3)] d(1)] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1853 | unfolding setsum_Un_disjoint[OF fths(2) fths(3) d(2)] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1854 | by simp | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1855 | finally have False using c' by simp} | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1856 | then have thn: "xs!i < n" by arith | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1857 | from h[rule_format, OF thn] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1858 | show "a$(xs !i) = ?r$(xs!i)" . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1859 | qed | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1860 | have th00: "\<And>(x::'a). of_nat (Suc k) * (x * inverse (of_nat (Suc k))) = x" | 
| 36350 | 1861 | by (simp add: field_simps del: of_nat_Suc) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1862 | from H have "b$n = a^Suc k $ n" by (simp add: fps_eq_iff) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1863 | also have "a ^ Suc k$n = setsum ?g ?Pnkn + setsum ?g ?Pnknn" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1864 | unfolding fps_power_nth_Suc | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1865 | using setsum_Un_disjoint[OF f d, unfolded Suc_eq_plus1[symmetric], | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1866 | unfolded eq, of ?g] by simp | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1867 | also have "\<dots> = of_nat (k+1) * a $ n * (?r $ 0)^k + setsum ?f ?Pnknn" unfolding th0 th1 .. | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1868 | finally have "of_nat (k+1) * a $ n * (?r $ 0)^k = b$n - setsum ?f ?Pnknn" by simp | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1869 | then have "a$n = (b$n - setsum ?f ?Pnknn) / (of_nat (k+1) * (?r $ 0)^k)" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1870 | apply - | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1871 | apply (rule eq_divide_imp') | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1872 | using r00 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1873 | apply (simp del: of_nat_Suc) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1874 | by (simp add: mult_ac) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1875 | then have "a$n = ?r $n" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1876 | apply (simp del: of_nat_Suc) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1877 | unfolding fps_radical_def n1 | 
| 36350 | 1878 | by (simp add: field_simps n1 th00 del: of_nat_Suc)} | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 1879 | ultimately show "a$n = ?r $ n" by (cases n, auto) | 
| 29687 | 1880 | qed} | 
| 1881 | then have "a = ?r" by (simp add: fps_eq_iff)} | |
| 1882 | ultimately show ?thesis by blast | |
| 1883 | qed | |
| 1884 | ||
| 1885 | ||
| 30488 | 1886 | lemma radical_power: | 
| 1887 | assumes r0: "r (Suc k) ((a$0) ^ Suc k) = a$0" | |
| 31273 | 1888 | and a0: "(a$0 ::'a::field_char_0) \<noteq> 0" | 
| 29687 | 1889 | shows "(fps_radical r (Suc k) (a ^ Suc k)) = a" | 
| 1890 | proof- | |
| 1891 | let ?ak = "a^ Suc k" | |
| 30273 
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
 huffman parents: 
29915diff
changeset | 1892 | have ak0: "?ak $ 0 = (a$0) ^ Suc k" by (simp add: fps_nth_power_0 del: power_Suc) | 
| 29687 | 1893 | from r0 have th0: "r (Suc k) (a ^ Suc k $ 0) ^ Suc k = a ^ Suc k $ 0" using ak0 by auto | 
| 1894 | from r0 ak0 have th1: "r (Suc k) (a ^ Suc k $ 0) = a $ 0" by auto | |
| 1895 | from ak0 a0 have ak00: "?ak $ 0 \<noteq>0 " by auto | |
| 1896 | from radical_unique[of r k ?ak a, OF th0 th1 ak00] show ?thesis by metis | |
| 1897 | qed | |
| 1898 | ||
| 30488 | 1899 | lemma fps_deriv_radical: | 
| 31273 | 1900 | fixes a:: "'a::field_char_0 fps" | 
| 29687 | 1901 | assumes r0: "(r (Suc k) (a$0)) ^ Suc k = a$0" and a0: "a$0 \<noteq> 0" | 
| 1902 | shows "fps_deriv (fps_radical r (Suc k) a) = fps_deriv a / (fps_const (of_nat (Suc k)) * (fps_radical r (Suc k) a) ^ k)" | |
| 1903 | proof- | |
| 1904 | let ?r= "fps_radical r (Suc k) a" | |
| 1905 | let ?w = "(fps_const (of_nat (Suc k)) * ?r ^ k)" | |
| 1906 | from a0 r0 have r0': "r (Suc k) (a$0) \<noteq> 0" by auto | |
| 1907 | from r0' have w0: "?w $ 0 \<noteq> 0" by (simp del: of_nat_Suc) | |
| 1908 | note th0 = inverse_mult_eq_1[OF w0] | |
| 1909 | let ?iw = "inverse ?w" | |
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1910 | from iffD1[OF power_radical[of a r], OF a0 r0] | 
| 29687 | 1911 | have "fps_deriv (?r ^ Suc k) = fps_deriv a" by simp | 
| 1912 | hence "fps_deriv ?r * ?w = fps_deriv a" | |
| 30273 
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
 huffman parents: 
29915diff
changeset | 1913 | by (simp add: fps_deriv_power mult_ac del: power_Suc) | 
| 29687 | 1914 | hence "?iw * fps_deriv ?r * ?w = ?iw * fps_deriv a" by simp | 
| 1915 | hence "fps_deriv ?r * (?iw * ?w) = fps_deriv a / ?w" | |
| 1916 | by (simp add: fps_divide_def) | |
| 30488 | 1917 | then show ?thesis unfolding th0 by simp | 
| 29687 | 1918 | qed | 
| 1919 | ||
| 30488 | 1920 | lemma radical_mult_distrib: | 
| 31273 | 1921 | fixes a:: "'a::field_char_0 fps" | 
| 48757 | 1922 | assumes k: "k > 0" | 
| 1923 | and ra0: "r k (a $ 0) ^ k = a $ 0" | |
| 1924 | and rb0: "r k (b $ 0) ^ k = b $ 0" | |
| 1925 | and a0: "a$0 \<noteq> 0" | |
| 1926 | and b0: "b$0 \<noteq> 0" | |
| 1927 | shows "r k ((a * b) $ 0) = r k (a $ 0) * r k (b $ 0) \<longleftrightarrow> | |
| 1928 | fps_radical r (k) (a*b) = fps_radical r (k) a * fps_radical r (k) (b)" | |
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1929 | proof- | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1930 |   {assume  r0': "r k ((a * b) $ 0) = r k (a $ 0) * r k (b $ 0)"
 | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1931 | from r0' have r0: "(r (k) ((a*b)$0)) ^ k = (a*b)$0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1932 | by (simp add: fps_mult_nth ra0 rb0 power_mult_distrib) | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1933 |   {assume "k=0" hence ?thesis using r0' by simp}
 | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1934 | moreover | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1935 |   {fix h assume k: "k = Suc h"
 | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1936 | let ?ra = "fps_radical r (Suc h) a" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1937 | let ?rb = "fps_radical r (Suc h) b" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1938 | have th0: "r (Suc h) ((a * b) $ 0) = (fps_radical r (Suc h) a * fps_radical r (Suc h) b) $ 0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1939 | using r0' k by (simp add: fps_mult_nth) | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1940 | have ab0: "(a*b) $ 0 \<noteq> 0" using a0 b0 by (simp add: fps_mult_nth) | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1941 | 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] | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1942 | iffD1[OF power_radical[of _ r], OF a0 ra0[unfolded k]] iffD1[OF power_radical[of _ r], OF b0 rb0[unfolded k]] k r0' | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1943 | have ?thesis by (auto simp add: power_mult_distrib simp del: power_Suc)} | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1944 | ultimately have ?thesis by (cases k, auto)} | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1945 | moreover | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1946 | {assume h: "fps_radical r k (a*b) = fps_radical r k a * fps_radical r k b"
 | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1947 | hence "(fps_radical r k (a*b))$0 = (fps_radical r k a * fps_radical r k b)$0" by simp | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1948 | then have "r k ((a * b) $ 0) = r k (a $ 0) * r k (b $ 0)" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1949 | using k by (simp add: fps_mult_nth)} | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1950 | ultimately show ?thesis by blast | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1951 | qed | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1952 | |
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1953 | (* | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1954 | lemma radical_mult_distrib: | 
| 31273 | 1955 | fixes a:: "'a::field_char_0 fps" | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1956 | assumes | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1957 | ra0: "r k (a $ 0) ^ k = a $ 0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1958 | and rb0: "r k (b $ 0) ^ k = b $ 0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1959 | and r0': "r k ((a * b) $ 0) = r k (a $ 0) * r k (b $ 0)" | 
| 29687 | 1960 | and a0: "a$0 \<noteq> 0" | 
| 1961 | and b0: "b$0 \<noteq> 0" | |
| 1962 | shows "fps_radical r (k) (a*b) = fps_radical r (k) a * fps_radical r (k) (b)" | |
| 1963 | proof- | |
| 1964 | from r0' have r0: "(r (k) ((a*b)$0)) ^ k = (a*b)$0" | |
| 1965 | by (simp add: fps_mult_nth ra0 rb0 power_mult_distrib) | |
| 1966 |   {assume "k=0" hence ?thesis by simp}
 | |
| 1967 | moreover | |
| 1968 |   {fix h assume k: "k = Suc h"
 | |
| 1969 | let ?ra = "fps_radical r (Suc h) a" | |
| 1970 | let ?rb = "fps_radical r (Suc h) b" | |
| 30488 | 1971 | have th0: "r (Suc h) ((a * b) $ 0) = (fps_radical r (Suc h) a * fps_radical r (Suc h) b) $ 0" | 
| 29687 | 1972 | using r0' k by (simp add: fps_mult_nth) | 
| 1973 | have ab0: "(a*b) $ 0 \<noteq> 0" using a0 b0 by (simp add: fps_mult_nth) | |
| 30488 | 1974 | 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 | 1975 | 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 | 1976 | have ?thesis by (auto simp add: power_mult_distrib simp del: power_Suc)} | 
| 29687 | 1977 | ultimately show ?thesis by (cases k, auto) | 
| 1978 | qed | |
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1979 | *) | 
| 29687 | 1980 | |
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1981 | lemma fps_divide_1[simp]: "(a:: ('a::field) fps) / 1 = a"
 | 
| 29687 | 1982 | by (simp add: fps_divide_def) | 
| 1983 | ||
| 1984 | lemma radical_divide: | |
| 31273 | 1985 | fixes a :: "'a::field_char_0 fps" | 
| 30488 | 1986 | assumes | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1987 | kp: "k>0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1988 | and ra0: "(r k (a $ 0)) ^ k = a $ 0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1989 | and rb0: "(r k (b $ 0)) ^ k = b $ 0" | 
| 30488 | 1990 | and a0: "a$0 \<noteq> 0" | 
| 29687 | 1991 | and b0: "b$0 \<noteq> 0" | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1992 | shows "r k ((a $ 0) / (b$0)) = r k (a$0) / r k (b $ 0) \<longleftrightarrow> fps_radical r k (a/b) = fps_radical r k a / fps_radical r k b" (is "?lhs = ?rhs") | 
| 29687 | 1993 | proof- | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1994 | let ?r = "fps_radical r k" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1995 | from kp obtain h where k: "k = Suc h" by (cases k, auto) | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1996 | 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 | 1997 | have rb0': "r k (b$0) \<noteq> 0" using b0 rb0 k by auto | 
| 30488 | 1998 | |
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 1999 |   {assume ?rhs
 | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2000 | then have "?r (a/b) $ 0 = (?r a / ?r b)$0" by simp | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2001 | then have ?lhs using k a0 b0 rb0' | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2002 | by (simp add: fps_divide_def fps_mult_nth fps_inverse_def divide_inverse) } | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2003 | moreover | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2004 |   {assume h: ?lhs
 | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2005 | from a0 b0 have ab0[simp]: "(a/b)$0 = a$0 / b$0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2006 | 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 | 2007 | have th0: "r k ((a/b)$0) ^ k = (a/b)$0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2008 | by (simp add: h nonzero_power_divide[OF rb0'] ra0 rb0 del: k) | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2009 | from a0 b0 ra0' rb0' kp h | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2010 | have th1: "r k ((a / b) $ 0) = (fps_radical r k a / fps_radical r k b) $ 0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2011 | by (simp add: fps_divide_def fps_mult_nth fps_inverse_def divide_inverse del: k) | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2012 | from a0 b0 ra0' rb0' kp have ab0': "(a / b) $ 0 \<noteq> 0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2013 | by (simp add: fps_divide_def fps_mult_nth fps_inverse_def nonzero_imp_inverse_nonzero) | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2014 | 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 | 2015 | note thb[simp] = iffD1[OF power_radical[where r=r and k=h], OF b0 rb0[unfolded k], unfolded k[symmetric]] | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2016 | have th2: "(?r a / ?r b)^k = a/b" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2017 | by (simp add: fps_divide_def power_mult_distrib fps_inverse_power[symmetric]) | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2018 | 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] have ?rhs .} | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2019 | ultimately show ?thesis by blast | 
| 29687 | 2020 | qed | 
| 2021 | ||
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2022 | lemma radical_inverse: | 
| 31273 | 2023 | fixes a :: "'a::field_char_0 fps" | 
| 31073 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2024 | assumes | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2025 | k: "k>0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2026 | and ra0: "r k (a $ 0) ^ k = a $ 0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2027 | and r1: "(r k 1)^k = 1" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2028 | and a0: "a$0 \<noteq> 0" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2029 | shows "r k (inverse (a $ 0)) = r k 1 / (r k (a $ 0)) \<longleftrightarrow> fps_radical r k (inverse a) = fps_radical r k 1 / fps_radical r k a" | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2030 | 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 | 2031 | by (simp add: divide_inverse fps_divide_def) | 
| 
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
 chaieb parents: 
31021diff
changeset | 2032 | |
| 29906 | 2033 | subsection{* Derivative of composition *}
 | 
| 29687 | 2034 | |
| 30488 | 2035 | lemma fps_compose_deriv: | 
| 29687 | 2036 |   fixes a:: "('a::idom) fps"
 | 
| 2037 | assumes b0: "b$0 = 0" | |
| 2038 | shows "fps_deriv (a oo b) = ((fps_deriv a) oo b) * (fps_deriv b)" | |
| 2039 | proof- | |
| 2040 |   {fix n
 | |
| 2041 |     have "(fps_deriv (a oo b))$n = setsum (\<lambda>i. a $ i * (fps_deriv (b^i))$n) {0.. Suc n}"
 | |
| 36350 | 2042 | by (simp add: fps_compose_def field_simps setsum_right_distrib del: of_nat_Suc) | 
| 29687 | 2043 |     also have "\<dots> = setsum (\<lambda>i. a$i * ((fps_const (of_nat i)) * (fps_deriv b * (b^(i - 1))))$n) {0.. Suc n}"
 | 
| 36350 | 2044 | by (simp add: field_simps fps_deriv_power del: fps_mult_left_const_nth of_nat_Suc) | 
| 29687 | 2045 |   also have "\<dots> = setsum (\<lambda>i. of_nat i * a$i * (((b^(i - 1)) * fps_deriv b))$n) {0.. Suc n}"
 | 
| 36350 | 2046 | unfolding fps_mult_left_const_nth by (simp add: field_simps) | 
| 29687 | 2047 |   also have "\<dots> = setsum (\<lambda>i. of_nat i * a$i * (setsum (\<lambda>j. (b^ (i - 1))$j * (fps_deriv b)$(n - j)) {0..n})) {0.. Suc n}"
 | 
| 2048 | unfolding fps_mult_nth .. | |
| 2049 |   also have "\<dots> = setsum (\<lambda>i. of_nat i * a$i * (setsum (\<lambda>j. (b^ (i - 1))$j * (fps_deriv b)$(n - j)) {0..n})) {1.. Suc n}"
 | |
| 2050 | apply (rule setsum_mono_zero_right) | |
| 29913 | 2051 | apply (auto simp add: mult_delta_left setsum_delta not_le) | 
| 2052 | done | |
| 29687 | 2053 |   also have "\<dots> = setsum (\<lambda>i. of_nat (i + 1) * a$(i+1) * (setsum (\<lambda>j. (b^ i)$j * of_nat (n - j + 1) * b$(n - j + 1)) {0..n})) {0.. n}"
 | 
| 2054 | unfolding fps_deriv_nth | |
| 37388 | 2055 | apply (rule setsum_reindex_cong [where f = Suc]) | 
| 29687 | 2056 | by (auto simp add: mult_assoc) | 
| 2057 |   finally have th0: "(fps_deriv (a oo b))$n = setsum (\<lambda>i. of_nat (i + 1) * a$(i+1) * (setsum (\<lambda>j. (b^ i)$j * of_nat (n - j + 1) * b$(n - j + 1)) {0..n})) {0.. n}" .
 | |
| 30488 | 2058 | |
| 29687 | 2059 |   have "(((fps_deriv a) oo b) * (fps_deriv b))$n = setsum (\<lambda>i. (fps_deriv b)$ (n - i) * ((fps_deriv a) oo b)$i) {0..n}"
 | 
| 2060 | unfolding fps_mult_nth by (simp add: mult_ac) | |
| 2061 |   also have "\<dots> = setsum (\<lambda>i. setsum (\<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}"
 | |
| 2062 | unfolding fps_deriv_nth fps_compose_nth setsum_right_distrib mult_assoc | |
| 2063 | apply (rule setsum_cong2) | |
| 2064 | apply (rule setsum_mono_zero_left) | |
| 2065 | apply (simp_all add: subset_eq) | |
| 2066 | apply clarify | |
| 2067 | apply (subgoal_tac "b^i$x = 0") | |
| 2068 | apply simp | |
| 2069 | apply (rule startsby_zero_power_prefix[OF b0, rule_format]) | |
| 2070 | by simp | |
| 2071 |   also have "\<dots> = setsum (\<lambda>i. of_nat (i + 1) * a$(i+1) * (setsum (\<lambda>j. (b^ i)$j * of_nat (n - j + 1) * b$(n - j + 1)) {0..n})) {0.. n}"
 | |
| 2072 | unfolding setsum_right_distrib | |
| 2073 | apply (subst setsum_commute) | |
| 2074 | by ((rule setsum_cong2)+) simp | |
| 2075 | finally have "(fps_deriv (a oo b))$n = (((fps_deriv a) oo b) * (fps_deriv b)) $n" | |
| 2076 | unfolding th0 by simp} | |
| 2077 | then show ?thesis by (simp add: fps_eq_iff) | |
| 2078 | qed | |
| 2079 | ||
| 2080 | lemma fps_mult_X_plus_1_nth: | |
| 2081 | "((1+X)*a) $n = (if n = 0 then (a$n :: 'a::comm_ring_1) else a$n + a$(n - 1))" | |
| 2082 | proof- | |
| 2083 |   {assume "n = 0" hence ?thesis by (simp add: fps_mult_nth )}
 | |
| 2084 | moreover | |
| 2085 |   {fix m assume m: "n = Suc m"
 | |
| 2086 |     have "((1+X)*a) $n = setsum (\<lambda>i. (1+X)$i * a$(n-i)) {0..n}"
 | |
| 2087 | by (simp add: fps_mult_nth) | |
| 2088 |     also have "\<dots> = setsum (\<lambda>i. (1+X)$i * a$(n-i)) {0.. 1}"
 | |
| 2089 | unfolding m | |
| 2090 | apply (rule setsum_mono_zero_right) | |
| 2091 | by (auto simp add: ) | |
| 2092 | also have "\<dots> = (if n = 0 then (a$n :: 'a::comm_ring_1) else a$n + a$(n - 1))" | |
| 2093 | unfolding m | |
| 2094 | by (simp add: ) | |
| 2095 | finally have ?thesis .} | |
| 2096 | ultimately show ?thesis by (cases n, auto) | |
| 2097 | qed | |
| 2098 | ||
| 29906 | 2099 | subsection{* Finite FPS (i.e. polynomials) and X *}
 | 
| 29687 | 2100 | lemma fps_poly_sum_X: | 
| 30488 | 2101 | assumes z: "\<forall>i > n. a$i = (0::'a::comm_ring_1)" | 
| 29687 | 2102 |   shows "a = setsum (\<lambda>i. fps_const (a$i) * X^i) {0..n}" (is "a = ?r")
 | 
| 2103 | proof- | |
| 2104 |   {fix i
 | |
| 30488 | 2105 | have "a$i = ?r$i" | 
| 29687 | 2106 | unfolding fps_setsum_nth fps_mult_left_const_nth X_power_nth | 
| 29913 | 2107 | by (simp add: mult_delta_right setsum_delta' z) | 
| 2108 | } | |
| 29687 | 2109 | then show ?thesis unfolding fps_eq_iff by blast | 
| 2110 | qed | |
| 2111 | ||
| 29906 | 2112 | subsection{* Compositional inverses *}
 | 
| 29687 | 2113 | |
| 2114 | ||
| 31021 | 2115 | fun compinv :: "'a fps \<Rightarrow> nat \<Rightarrow> 'a::{field}" where
 | 
| 29687 | 2116 | "compinv a 0 = X$0" | 
| 2117 | | "compinv a (Suc n) = (X$ Suc n - setsum (\<lambda>i. (compinv a i) * (a^i)$Suc n) {0 .. n}) / (a$1) ^ Suc n"
 | |
| 2118 | ||
| 2119 | definition "fps_inv a = Abs_fps (compinv a)" | |
| 2120 | ||
| 2121 | lemma fps_inv: assumes a0: "a$0 = 0" and a1: "a$1 \<noteq> 0" | |
| 2122 | shows "fps_inv a oo a = X" | |
| 2123 | proof- | |
| 2124 | let ?i = "fps_inv a oo a" | |
| 2125 |   {fix n
 | |
| 30488 | 2126 | have "?i $n = X$n" | 
| 29687 | 2127 | proof(induct n rule: nat_less_induct) | 
| 2128 | fix n assume h: "\<forall>m<n. ?i$m = X$m" | |
| 30488 | 2129 |       {assume "n=0" hence "?i $n = X$n" using a0
 | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2130 | by (simp add: fps_compose_nth fps_inv_def)} | 
| 29687 | 2131 | moreover | 
| 2132 |       {fix n1 assume n1: "n = Suc n1"
 | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2133 |         have "?i $ n = setsum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1} + fps_inv a $ Suc n1 * (a $ 1)^ Suc n1"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2134 | by (simp add: fps_compose_nth n1 startsby_zero_power_nth_same[OF a0] | 
| 30273 
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
 huffman parents: 
29915diff
changeset | 2135 | del: power_Suc) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2136 |         also have "\<dots> = setsum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1} + (X$ Suc n1 - setsum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1})"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2137 | using a0 a1 n1 by (simp add: fps_inv_def) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2138 | also have "\<dots> = X$n" using n1 by simp | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2139 | finally have "?i $ n = X$n" .} | 
| 29687 | 2140 | ultimately show "?i $ n = X$n" by (cases n, auto) | 
| 2141 | qed} | |
| 2142 | then show ?thesis by (simp add: fps_eq_iff) | |
| 2143 | qed | |
| 2144 | ||
| 2145 | ||
| 31021 | 2146 | fun gcompinv :: "'a fps \<Rightarrow> 'a fps \<Rightarrow> nat \<Rightarrow> 'a::{field}" where
 | 
| 29687 | 2147 | "gcompinv b a 0 = b$0" | 
| 2148 | | "gcompinv b a (Suc n) = (b$ Suc n - setsum (\<lambda>i. (gcompinv b a i) * (a^i)$Suc n) {0 .. n}) / (a$1) ^ Suc n"
 | |
| 2149 | ||
| 2150 | definition "fps_ginv b a = Abs_fps (gcompinv b a)" | |
| 2151 | ||
| 2152 | lemma fps_ginv: assumes a0: "a$0 = 0" and a1: "a$1 \<noteq> 0" | |
| 2153 | shows "fps_ginv b a oo a = b" | |
| 2154 | proof- | |
| 2155 | let ?i = "fps_ginv b a oo a" | |
| 2156 |   {fix n
 | |
| 30488 | 2157 | have "?i $n = b$n" | 
| 29687 | 2158 | proof(induct n rule: nat_less_induct) | 
| 2159 | fix n assume h: "\<forall>m<n. ?i$m = b$m" | |
| 30488 | 2160 |       {assume "n=0" hence "?i $n = b$n" using a0
 | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2161 | by (simp add: fps_compose_nth fps_ginv_def)} | 
| 29687 | 2162 | moreover | 
| 2163 |       {fix n1 assume n1: "n = Suc n1"
 | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2164 |         have "?i $ n = setsum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1} + fps_ginv b a $ Suc n1 * (a $ 1)^ Suc n1"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2165 | by (simp add: fps_compose_nth n1 startsby_zero_power_nth_same[OF a0] | 
| 30273 
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
 huffman parents: 
29915diff
changeset | 2166 | del: power_Suc) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2167 |         also have "\<dots> = setsum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1} + (b$ Suc n1 - setsum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1})"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2168 | using a0 a1 n1 by (simp add: fps_ginv_def) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2169 | also have "\<dots> = b$n" using n1 by simp | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2170 | finally have "?i $ n = b$n" .} | 
| 29687 | 2171 | ultimately show "?i $ n = b$n" by (cases n, auto) | 
| 2172 | qed} | |
| 2173 | then show ?thesis by (simp add: fps_eq_iff) | |
| 2174 | qed | |
| 2175 | ||
| 2176 | 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 | 2177 | apply (auto simp add: fun_eq_iff fps_eq_iff fps_inv_def fps_ginv_def) | 
| 48757 | 2178 | apply (induct_tac n rule: nat_less_induct) | 
| 2179 | apply auto | |
| 29687 | 2180 | apply (case_tac na) | 
| 2181 | apply simp | |
| 2182 | apply simp | |
| 2183 | done | |
| 2184 | ||
| 2185 | lemma fps_compose_1[simp]: "1 oo a = 1" | |
| 30960 | 2186 | by (simp add: fps_eq_iff fps_compose_nth mult_delta_left setsum_delta) | 
| 29687 | 2187 | |
| 2188 | lemma fps_compose_0[simp]: "0 oo a = 0" | |
| 29913 | 2189 | by (simp add: fps_eq_iff fps_compose_nth) | 
| 29687 | 2190 | |
| 2191 | lemma fps_compose_0_right[simp]: "a oo 0 = fps_const (a$0)" | |
| 30960 | 2192 | by (auto simp add: fps_eq_iff fps_compose_nth power_0_left setsum_0') | 
| 29687 | 2193 | |
| 2194 | lemma fps_compose_add_distrib: "(a + b) oo c = (a oo c) + (b oo c)" | |
| 36350 | 2195 | by (simp add: fps_eq_iff fps_compose_nth field_simps setsum_addf) | 
| 29687 | 2196 | |
| 2197 | lemma fps_compose_setsum_distrib: "(setsum f S) oo a = setsum (\<lambda>i. f i oo a) S" | |
| 2198 | proof- | |
| 2199 |   {assume "\<not> finite S" hence ?thesis by simp}
 | |
| 2200 | moreover | |
| 2201 |   {assume fS: "finite S"
 | |
| 2202 | have ?thesis | |
| 2203 | proof(rule finite_induct[OF fS]) | |
| 2204 |       show "setsum f {} oo a = (\<Sum>i\<in>{}. f i oo a)" by simp
 | |
| 2205 | next | |
| 2206 | fix x F assume fF: "finite F" and xF: "x \<notin> F" and h: "setsum f F oo a = setsum (\<lambda>i. f i oo a) F" | |
| 2207 | show "setsum f (insert x F) oo a = setsum (\<lambda>i. f i oo a) (insert x F)" | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2208 | using fF xF h by (simp add: fps_compose_add_distrib) | 
| 29687 | 2209 | qed} | 
| 30488 | 2210 | ultimately show ?thesis by blast | 
| 29687 | 2211 | qed | 
| 2212 | ||
| 30488 | 2213 | lemma convolution_eq: | 
| 29687 | 2214 |   "setsum (%i. a (i :: nat) * b (n - i)) {0 .. n} = setsum (%(i,j). a i * b j) {(i,j). i <= n \<and> j \<le> n \<and> i + j = n}"
 | 
| 2215 | apply (rule setsum_reindex_cong[where f=fst]) | |
| 2216 | apply (clarsimp simp add: inj_on_def) | |
| 39302 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 nipkow parents: 
39198diff
changeset | 2217 | apply (auto simp add: set_eq_iff image_iff) | 
| 29687 | 2218 | apply (rule_tac x= "x" in exI) | 
| 2219 | apply clarsimp | |
| 2220 | apply (rule_tac x="n - x" in exI) | |
| 2221 | apply arith | |
| 2222 | done | |
| 2223 | ||
| 2224 | lemma product_composition_lemma: | |
| 2225 | assumes c0: "c$0 = (0::'a::idom)" and d0: "d$0 = 0" | |
| 2226 |   shows "((a oo c) * (b oo d))$n = setsum (%(k,m). a$k * b$m * (c^k * d^m) $ n) {(k,m). k + m \<le> n}" (is "?l = ?r")
 | |
| 2227 | proof- | |
| 2228 |   let ?S = "{(k\<Colon>nat, m\<Colon>nat). k + m \<le> n}"
 | |
| 30488 | 2229 |   have s: "?S \<subseteq> {0..n} <*> {0..n}" by (auto simp add: subset_eq)
 | 
| 2230 |   have f: "finite {(k\<Colon>nat, m\<Colon>nat). k + m \<le> n}"
 | |
| 29687 | 2231 | apply (rule finite_subset[OF s]) | 
| 2232 | by auto | |
| 2233 |   have "?r =  setsum (%i. setsum (%(k,m). a$k * (c^k)$i * b$m * (d^m) $ (n - i)) {(k,m). k + m \<le> n}) {0..n}"
 | |
| 2234 | apply (simp add: fps_mult_nth setsum_right_distrib) | |
| 2235 | apply (subst setsum_commute) | |
| 2236 | apply (rule setsum_cong2) | |
| 36350 | 2237 | by (auto simp add: field_simps) | 
| 30488 | 2238 | also have "\<dots> = ?l" | 
| 29687 | 2239 | apply (simp add: fps_mult_nth fps_compose_nth setsum_product) | 
| 2240 | apply (rule setsum_cong2) | |
| 2241 | apply (simp add: setsum_cartesian_product mult_assoc) | |
| 2242 | apply (rule setsum_mono_zero_right[OF f]) | |
| 2243 | apply (simp add: subset_eq) apply presburger | |
| 2244 | apply clarsimp | |
| 2245 | apply (rule ccontr) | |
| 2246 | apply (clarsimp simp add: not_le) | |
| 2247 | apply (case_tac "x < aa") | |
| 2248 | apply simp | |
| 2249 | apply (frule_tac startsby_zero_power_prefix[rule_format, OF c0]) | |
| 2250 | apply blast | |
| 2251 | apply simp | |
| 2252 | apply (frule_tac startsby_zero_power_prefix[rule_format, OF d0]) | |
| 2253 | apply blast | |
| 2254 | done | |
| 2255 | finally show ?thesis by simp | |
| 2256 | qed | |
| 2257 | ||
| 2258 | lemma product_composition_lemma': | |
| 2259 | assumes c0: "c$0 = (0::'a::idom)" and d0: "d$0 = 0" | |
| 2260 |   shows "((a oo c) * (b oo d))$n = setsum (%k. setsum (%m. a$k * b$m * (c^k * d^m) $ n) {0..n}) {0..n}" (is "?l = ?r")
 | |
| 2261 | unfolding product_composition_lemma[OF c0 d0] | |
| 2262 | unfolding setsum_cartesian_product | |
| 2263 | apply (rule setsum_mono_zero_left) | |
| 2264 | apply simp | |
| 2265 | apply (clarsimp simp add: subset_eq) | |
| 2266 | apply clarsimp | |
| 2267 | apply (rule ccontr) | |
| 2268 | apply (subgoal_tac "(c^aa * d^ba) $ n = 0") | |
| 2269 | apply simp | |
| 2270 | unfolding fps_mult_nth | |
| 2271 | apply (rule setsum_0') | |
| 2272 | apply (clarsimp simp add: not_le) | |
| 2273 | apply (case_tac "aaa < aa") | |
| 2274 | apply (rule startsby_zero_power_prefix[OF c0, rule_format]) | |
| 2275 | apply simp | |
| 2276 | apply (subgoal_tac "n - aaa < ba") | |
| 2277 | apply (frule_tac k = "ba" in startsby_zero_power_prefix[OF d0, rule_format]) | |
| 2278 | apply simp | |
| 2279 | apply arith | |
| 2280 | done | |
| 30488 | 2281 | |
| 29687 | 2282 | |
| 30488 | 2283 | lemma setsum_pair_less_iff: | 
| 29687 | 2284 |   "setsum (%((k::nat),m). a k * b m * c (k + m)) {(k,m). k + m \<le> n} = setsum (%s. setsum (%i. a i * b (s - i) * c s) {0..s}) {0..n}" (is "?l = ?r")
 | 
| 2285 | proof- | |
| 2286 |   let ?KM=  "{(k,m). k + m \<le> n}"
 | |
| 2287 |   let ?f = "%s. UNION {(0::nat)..s} (%i. {(i,s - i)})"
 | |
| 2288 |   have th0: "?KM = UNION {0..n} ?f"
 | |
| 39302 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 nipkow parents: 
39198diff
changeset | 2289 | apply (simp add: set_eq_iff) | 
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 2290 | apply arith (* FIXME: VERY slow! *) | 
| 29687 | 2291 | done | 
| 2292 | show "?l = ?r " | |
| 2293 | unfolding th0 | |
| 2294 | apply (subst setsum_UN_disjoint) | |
| 2295 | apply auto | |
| 2296 | apply (subst setsum_UN_disjoint) | |
| 2297 | apply auto | |
| 2298 | done | |
| 2299 | qed | |
| 2300 | ||
| 2301 | lemma fps_compose_mult_distrib_lemma: | |
| 2302 | assumes c0: "c$0 = (0::'a::idom)" | |
| 2303 |   shows "((a oo c) * (b oo c))$n = setsum (%s. setsum (%i. a$i * b$(s - i) * (c^s) $ n) {0..s}) {0..n}" (is "?l = ?r")
 | |
| 2304 | unfolding product_composition_lemma[OF c0 c0] power_add[symmetric] | |
| 2305 | unfolding setsum_pair_less_iff[where a = "%k. a$k" and b="%m. b$m" and c="%s. (c ^ s)$n" and n = n] .. | |
| 2306 | ||
| 2307 | ||
| 30488 | 2308 | lemma fps_compose_mult_distrib: | 
| 29687 | 2309 | assumes c0: "c$0 = (0::'a::idom)" | 
| 2310 | shows "(a * b) oo c = (a oo c) * (b oo c)" (is "?l = ?r") | |
| 2311 | apply (simp add: fps_eq_iff fps_compose_mult_distrib_lemma[OF c0]) | |
| 2312 | by (simp add: fps_compose_nth fps_mult_nth setsum_left_distrib) | |
| 30488 | 2313 | lemma fps_compose_setprod_distrib: | 
| 29687 | 2314 | assumes c0: "c$0 = (0::'a::idom)" | 
| 2315 | shows "(setprod a S) oo c = setprod (%k. a k oo c) S" (is "?l = ?r") | |
| 2316 | apply (cases "finite S") | |
| 2317 | apply simp_all | |
| 2318 | apply (induct S rule: finite_induct) | |
| 2319 | apply simp | |
| 2320 | apply (simp add: fps_compose_mult_distrib[OF c0]) | |
| 2321 | done | |
| 2322 | ||
| 2323 | lemma fps_compose_power: assumes c0: "c$0 = (0::'a::idom)" | |
| 2324 | shows "(a oo c)^n = a^n oo c" (is "?l = ?r") | |
| 2325 | proof- | |
| 2326 |   {assume "n=0" then have ?thesis by simp}
 | |
| 2327 | moreover | |
| 2328 |   {fix m assume m: "n = Suc m"
 | |
| 2329 |     have th0: "a^n = setprod (%k. a) {0..m}" "(a oo c) ^ n = setprod (%k. a oo c) {0..m}"
 | |
| 2330 | by (simp_all add: setprod_constant m) | |
| 2331 | then have ?thesis | |
| 2332 | by (simp add: fps_compose_setprod_distrib[OF c0])} | |
| 2333 | ultimately show ?thesis by (cases n, auto) | |
| 2334 | qed | |
| 2335 | ||
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2336 | lemma fps_compose_uminus: "- (a::'a::ring_1 fps) oo c = - (a oo c)" | 
| 36350 | 2337 | by (simp add: fps_eq_iff fps_compose_nth field_simps setsum_negf[symmetric]) | 
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2338 | |
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2339 | lemma fps_compose_sub_distrib: | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2340 | shows "(a - b) oo (c::'a::ring_1 fps) = (a oo c) - (b oo c)" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2341 | unfolding diff_minus fps_compose_uminus fps_compose_add_distrib .. | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2342 | |
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2343 | lemma X_fps_compose:"X oo a = Abs_fps (\<lambda>n. if n = 0 then (0::'a::comm_ring_1) else a$n)" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2344 | by (simp add: fps_eq_iff fps_compose_nth mult_delta_left setsum_delta power_Suc) | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2345 | |
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2346 | lemma fps_inverse_compose: | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2347 | assumes b0: "(b$0 :: 'a::field) = 0" and a0: "a$0 \<noteq> 0" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2348 | shows "inverse a oo b = inverse (a oo b)" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2349 | proof- | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2350 | let ?ia = "inverse a" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2351 | let ?ab = "a oo b" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2352 | let ?iab = "inverse ?ab" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2353 | |
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2354 | from a0 have ia0: "?ia $ 0 \<noteq> 0" by (simp ) | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2355 | from a0 have ab0: "?ab $ 0 \<noteq> 0" by (simp add: fps_compose_def) | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2356 | have "(?ia oo b) * (a oo b) = 1" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2357 | unfolding fps_compose_mult_distrib[OF b0, symmetric] | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2358 | unfolding inverse_mult_eq_1[OF a0] | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2359 | fps_compose_1 .. | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2360 | |
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2361 | then have "(?ia oo b) * (a oo b) * ?iab = 1 * ?iab" by simp | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2362 | then have "(?ia oo b) * (?iab * (a oo b)) = ?iab" by simp | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2363 | then show ?thesis | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2364 | unfolding inverse_mult_eq_1[OF ab0] by simp | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2365 | qed | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2366 | |
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2367 | lemma fps_divide_compose: | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2368 | assumes c0: "(c$0 :: 'a::field) = 0" and b0: "b$0 \<noteq> 0" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2369 | shows "(a/b) oo c = (a oo c) / (b oo c)" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2370 | unfolding fps_divide_def fps_compose_mult_distrib[OF c0] | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2371 | fps_inverse_compose[OF c0 b0] .. | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2372 | |
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2373 | lemma gp: assumes a0: "a$0 = (0::'a::field)" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2374 | shows "(Abs_fps (\<lambda>n. 1)) oo a = 1/(1 - a)" (is "?one oo a = _") | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2375 | proof- | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2376 | have o0: "?one $ 0 \<noteq> 0" by simp | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2377 | have th0: "(1 - X) $ 0 \<noteq> (0::'a)" by simp | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2378 | 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 | 2379 | have "inverse ?one = 1 - X" by (simp add: fps_eq_iff) | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2380 | hence "inverse (inverse ?one) = inverse (1 - X)" by simp | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2381 | hence th: "?one = 1/(1 - X)" unfolding fps_inverse_idempotent[OF o0] | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2382 | by (simp add: fps_divide_def) | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2383 | show ?thesis unfolding th | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2384 | 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 | 2385 | 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 | 2386 | qed | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2387 | |
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2388 | lemma fps_const_power[simp]: "fps_const (c::'a::ring_1) ^ n = fps_const (c^n)" | 
| 48757 | 2389 | by (induct n) auto | 
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2390 | |
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2391 | lemma fps_compose_radical: | 
| 31273 | 2392 | assumes b0: "b$0 = (0::'a::field_char_0)" | 
| 31199 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2393 | and ra0: "r (Suc k) (a$0) ^ Suc k = a$0" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2394 | and a0: "a$0 \<noteq> 0" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2395 | shows "fps_radical r (Suc k) a oo b = fps_radical r (Suc k) (a oo b)" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2396 | proof- | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2397 | 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 | 2398 | let ?ab = "a oo b" | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2399 | have ab0: "?ab $ 0 = a$0" by (simp add: fps_compose_def) | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2400 | from ab0 a0 ra0 have rab0: "?ab $ 0 \<noteq> 0" "r (Suc k) (?ab $ 0) ^ Suc k = ?ab $ 0" by simp_all | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2401 | 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 | 2402 | 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 | 2403 | 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 | 2404 | unfolding fps_compose_power[OF b0] | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2405 | unfolding iffD1[OF power_radical[of a r k], OF a0 ra0] .. | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2406 | 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] show ?thesis . | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2407 | qed | 
| 
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
 chaieb parents: 
31148diff
changeset | 2408 | |
| 29687 | 2409 | lemma fps_const_mult_apply_left: | 
| 2410 | "fps_const c * (a oo b) = (fps_const c * a) oo b" | |
| 2411 | by (simp add: fps_eq_iff fps_compose_nth setsum_right_distrib mult_assoc) | |
| 2412 | ||
| 2413 | lemma fps_const_mult_apply_right: | |
| 2414 | "(a oo b) * fps_const (c::'a::comm_semiring_1) = (fps_const c * a) oo b" | |
| 2415 | by (auto simp add: fps_const_mult_apply_left mult_commute) | |
| 2416 | ||
| 30488 | 2417 | lemma fps_compose_assoc: | 
| 29687 | 2418 | assumes c0: "c$0 = (0::'a::idom)" and b0: "b$0 = 0" | 
| 2419 | shows "a oo (b oo c) = a oo b oo c" (is "?l = ?r") | |
| 2420 | proof- | |
| 2421 |   {fix n
 | |
| 2422 |     have "?l$n = (setsum (\<lambda>i. (fps_const (a$i) * b^i) oo c) {0..n})$n"
 | |
| 2423 | by (simp add: fps_compose_nth fps_compose_power[OF c0] fps_const_mult_apply_left setsum_right_distrib mult_assoc fps_setsum_nth) | |
| 2424 |     also have "\<dots> = ((setsum (\<lambda>i. fps_const (a$i) * b^i) {0..n}) oo c)$n"
 | |
| 2425 | by (simp add: fps_compose_setsum_distrib) | |
| 2426 | also have "\<dots> = ?r$n" | |
| 2427 | apply (simp add: fps_compose_nth fps_setsum_nth setsum_left_distrib mult_assoc) | |
| 2428 | apply (rule setsum_cong2) | |
| 2429 | apply (rule setsum_mono_zero_right) | |
| 2430 | apply (auto simp add: not_le) | |
| 2431 | by (erule startsby_zero_power_prefix[OF b0, rule_format]) | |
| 2432 | finally have "?l$n = ?r$n" .} | |
| 2433 | then show ?thesis by (simp add: fps_eq_iff) | |
| 2434 | qed | |
| 2435 | ||
| 2436 | ||
| 2437 | lemma fps_X_power_compose: | |
| 2438 |   assumes a0: "a$0=0" shows "X^k oo a = (a::('a::idom fps))^k" (is "?l = ?r")
 | |
| 2439 | proof- | |
| 2440 |   {assume "k=0" hence ?thesis by simp}
 | |
| 2441 | moreover | |
| 2442 |   {fix h assume h: "k = Suc h"
 | |
| 2443 |     {fix n
 | |
| 30488 | 2444 |       {assume kn: "k>n" hence "?l $ n = ?r $n" using a0 startsby_zero_power_prefix[OF a0] h
 | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2445 | by (simp add: fps_compose_nth del: power_Suc)} | 
| 29687 | 2446 | moreover | 
| 2447 |       {assume kn: "k \<le> n"
 | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2448 | hence "?l$n = ?r$n" | 
| 29913 | 2449 | by (simp add: fps_compose_nth mult_delta_left setsum_delta)} | 
| 29687 | 2450 | moreover have "k >n \<or> k\<le> n" by arith | 
| 2451 | ultimately have "?l$n = ?r$n" by blast} | |
| 2452 | then have ?thesis unfolding fps_eq_iff by blast} | |
| 2453 | ultimately show ?thesis by (cases k, auto) | |
| 2454 | qed | |
| 2455 | ||
| 2456 | lemma fps_inv_right: assumes a0: "a$0 = 0" and a1: "a$1 \<noteq> 0" | |
| 2457 | shows "a oo fps_inv a = X" | |
| 2458 | proof- | |
| 2459 | let ?ia = "fps_inv a" | |
| 2460 | let ?iaa = "a oo fps_inv a" | |
| 2461 | have th0: "?ia $ 0 = 0" by (simp add: fps_inv_def) | |
| 30488 | 2462 | have th1: "?iaa $ 0 = 0" using a0 a1 | 
| 29687 | 2463 | by (simp add: fps_inv_def fps_compose_nth) | 
| 2464 | have th2: "X$0 = 0" by simp | |
| 2465 | from fps_inv[OF a0 a1] have "a oo (fps_inv a oo a) = a oo X" by simp | |
| 2466 | then have "(a oo fps_inv a) oo a = X oo a" | |
| 2467 | by (simp add: fps_compose_assoc[OF a0 th0] X_fps_compose_startby0[OF a0]) | |
| 2468 | with fps_compose_inj_right[OF a0 a1] | |
| 30488 | 2469 | show ?thesis by simp | 
| 29687 | 2470 | qed | 
| 2471 | ||
| 2472 | lemma fps_inv_deriv: | |
| 31021 | 2473 |   assumes a0:"a$0 = (0::'a::{field})" and a1: "a$1 \<noteq> 0"
 | 
| 29687 | 2474 | shows "fps_deriv (fps_inv a) = inverse (fps_deriv a oo fps_inv a)" | 
| 2475 | proof- | |
| 2476 | let ?ia = "fps_inv a" | |
| 2477 | let ?d = "fps_deriv a oo ?ia" | |
| 2478 | let ?dia = "fps_deriv ?ia" | |
| 2479 | have ia0: "?ia$0 = 0" by (simp add: fps_inv_def) | |
| 2480 | have th0: "?d$0 \<noteq> 0" using a1 by (simp add: fps_compose_nth fps_deriv_nth) | |
| 2481 | from fps_inv_right[OF a0 a1] have "?d * ?dia = 1" | |
| 2482 | by (simp add: fps_compose_deriv[OF ia0, of a, symmetric] ) | |
| 2483 | hence "inverse ?d * ?d * ?dia = inverse ?d * 1" by simp | |
| 2484 | with inverse_mult_eq_1[OF th0] | |
| 2485 | show "?dia = inverse ?d" by simp | |
| 2486 | qed | |
| 2487 | ||
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2488 | lemma fps_inv_idempotent: | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2489 | assumes a0: "a$0 = 0" and a1: "a$1 \<noteq> 0" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2490 | shows "fps_inv (fps_inv a) = a" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2491 | proof- | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2492 | let ?r = "fps_inv" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2493 | have ra0: "?r a $ 0 = 0" by (simp add: fps_inv_def) | 
| 36350 | 2494 | from a1 have ra1: "?r a $ 1 \<noteq> 0" by (simp add: fps_inv_def field_simps) | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2495 | have X0: "X$0 = 0" by simp | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2496 | from fps_inv[OF ra0 ra1] have "?r (?r a) oo ?r a = X" . | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2497 | then have "?r (?r a) oo ?r a oo a = X oo a" by simp | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2498 | then have "?r (?r a) oo (?r a oo a) = a" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2499 | unfolding X_fps_compose_startby0[OF a0] | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2500 | unfolding fps_compose_assoc[OF a0 ra0, symmetric] . | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2501 | then show ?thesis unfolding fps_inv[OF a0 a1] by simp | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2502 | qed | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2503 | |
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2504 | lemma fps_ginv_ginv: | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2505 | assumes a0: "a$0 = 0" and a1: "a$1 \<noteq> 0" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2506 | and c0: "c$0 = 0" and c1: "c$1 \<noteq> 0" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2507 | shows "fps_ginv b (fps_ginv c a) = b oo a oo fps_inv c" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2508 | proof- | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2509 | let ?r = "fps_ginv" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2510 | from c0 have rca0: "?r c a $0 = 0" by (simp add: fps_ginv_def) | 
| 36350 | 2511 | from a1 c1 have rca1: "?r c a $ 1 \<noteq> 0" by (simp add: fps_ginv_def field_simps) | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2512 | from fps_ginv[OF rca0 rca1] | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2513 | have "?r b (?r c a) oo ?r c a = b" . | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2514 | then have "?r b (?r c a) oo ?r c a oo a = b oo a" by simp | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2515 | 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 | 2516 | apply (subst fps_compose_assoc) | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2517 | using a0 c0 by (auto simp add: fps_ginv_def) | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2518 | then have "?r b (?r c a) oo c = b oo a" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2519 | unfolding fps_ginv[OF a0 a1] . | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2520 | then have "?r b (?r c a) oo c oo fps_inv c= b oo a oo fps_inv c" by simp | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2521 | 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 | 2522 | apply (subst fps_compose_assoc) | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2523 | using a0 c0 by (auto simp add: fps_inv_def) | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2524 | then show ?thesis unfolding fps_inv_right[OF c0 c1] by simp | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2525 | qed | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2526 | |
| 32410 | 2527 | lemma fps_ginv_deriv: | 
| 2528 |   assumes a0:"a$0 = (0::'a::{field})" and a1: "a$1 \<noteq> 0"
 | |
| 2529 | shows "fps_deriv (fps_ginv b a) = (fps_deriv b / fps_deriv a) oo fps_ginv X a" | |
| 2530 | proof- | |
| 2531 | let ?ia = "fps_ginv b a" | |
| 2532 | let ?iXa = "fps_ginv X a" | |
| 2533 | let ?d = "fps_deriv" | |
| 2534 | let ?dia = "?d ?ia" | |
| 2535 | have iXa0: "?iXa $ 0 = 0" by (simp add: fps_ginv_def) | |
| 2536 | have da0: "?d a $ 0 \<noteq> 0" using a1 by simp | |
| 2537 | from fps_ginv[OF a0 a1, of b] have "?d (?ia oo a) = fps_deriv b" by simp | |
| 2538 | then have "(?d ?ia oo a) * ?d a = ?d b" unfolding fps_compose_deriv[OF a0] . | |
| 2539 | then have "(?d ?ia oo a) * ?d a * inverse (?d a) = ?d b * inverse (?d a)" by simp | |
| 2540 | then have "(?d ?ia oo a) * (inverse (?d a) * ?d a) = ?d b / ?d a" | |
| 2541 | by (simp add: fps_divide_def) | |
| 2542 | then have "(?d ?ia oo a) oo ?iXa = (?d b / ?d a) oo ?iXa " | |
| 2543 | unfolding inverse_mult_eq_1[OF da0] by simp | |
| 2544 | then have "?d ?ia oo (a oo ?iXa) = (?d b / ?d a) oo ?iXa" | |
| 2545 | unfolding fps_compose_assoc[OF iXa0 a0] . | |
| 2546 | then show ?thesis unfolding fps_inv_ginv[symmetric] | |
| 2547 | unfolding fps_inv_right[OF a0 a1] by simp | |
| 2548 | qed | |
| 2549 | ||
| 29906 | 2550 | subsection{* Elementary series *}
 | 
| 29687 | 2551 | |
| 29906 | 2552 | subsubsection{* Exponential series *}
 | 
| 30488 | 2553 | definition "E x = Abs_fps (\<lambda>n. x^n / of_nat (fact n))" | 
| 29687 | 2554 | |
| 31273 | 2555 | lemma E_deriv[simp]: "fps_deriv (E a) = fps_const (a::'a::field_char_0) * E a" (is "?l = ?r") | 
| 29687 | 2556 | proof- | 
| 2557 |   {fix n
 | |
| 2558 | have "?l$n = ?r $ n" | |
| 36350 | 2559 | apply (auto simp add: E_def field_simps power_Suc[symmetric]simp del: fact_Suc of_nat_Suc power_Suc) | 
| 2560 | by (simp add: of_nat_mult field_simps)} | |
| 29687 | 2561 | then show ?thesis by (simp add: fps_eq_iff) | 
| 2562 | qed | |
| 2563 | ||
| 30488 | 2564 | lemma E_unique_ODE: | 
| 31273 | 2565 | "fps_deriv a = fps_const c * a \<longleftrightarrow> a = fps_const (a$0) * E (c :: 'a::field_char_0)" | 
| 29687 | 2566 | (is "?lhs \<longleftrightarrow> ?rhs") | 
| 2567 | proof- | |
| 2568 |   {assume d: ?lhs
 | |
| 30488 | 2569 | from d have th: "\<And>n. a $ Suc n = c * a$n / of_nat (Suc n)" | 
| 36350 | 2570 | by (simp add: fps_deriv_def fps_eq_iff field_simps del: of_nat_Suc) | 
| 29687 | 2571 |   {fix n have "a$n = a$0 * c ^ n/ (of_nat (fact n))"
 | 
| 2572 | apply (induct n) | |
| 2573 | apply simp | |
| 30488 | 2574 | unfolding th | 
| 32042 | 2575 | using fact_gt_zero_nat | 
| 36350 | 2576 | apply (simp add: field_simps del: of_nat_Suc fact_Suc) | 
| 29687 | 2577 | apply (drule sym) | 
| 36350 | 2578 | by (simp add: field_simps of_nat_mult power_Suc)} | 
| 29687 | 2579 | note th' = this | 
| 30488 | 2580 | have ?rhs | 
| 29687 | 2581 | by (auto simp add: fps_eq_iff fps_const_mult_left E_def intro : th')} | 
| 2582 | moreover | |
| 2583 | {assume h: ?rhs
 | |
| 30488 | 2584 | have ?lhs | 
| 29687 | 2585 | apply (subst h) | 
| 2586 | apply simp | |
| 2587 | apply (simp only: h[symmetric]) | |
| 2588 | by simp} | |
| 2589 | ultimately show ?thesis by blast | |
| 2590 | qed | |
| 2591 | ||
| 31273 | 2592 | lemma E_add_mult: "E (a + b) = E (a::'a::field_char_0) * E b" (is "?l = ?r") | 
| 29687 | 2593 | proof- | 
| 2594 | have "fps_deriv (?r) = fps_const (a+b) * ?r" | |
| 36350 | 2595 | by (simp add: fps_const_add[symmetric] field_simps del: fps_const_add) | 
| 29687 | 2596 | then have "?r = ?l" apply (simp only: E_unique_ODE) | 
| 2597 | by (simp add: fps_mult_nth E_def) | |
| 2598 | then show ?thesis .. | |
| 2599 | qed | |
| 2600 | ||
| 2601 | lemma E_nth[simp]: "E a $ n = a^n / of_nat (fact n)" | |
| 2602 | by (simp add: E_def) | |
| 2603 | ||
| 31021 | 2604 | lemma E0[simp]: "E (0::'a::{field}) = 1"
 | 
| 29687 | 2605 | by (simp add: fps_eq_iff power_0_left) | 
| 2606 | ||
| 31273 | 2607 | lemma E_neg: "E (- a) = inverse (E (a::'a::field_char_0))" | 
| 29687 | 2608 | proof- | 
| 2609 | from E_add_mult[of a "- a"] have th0: "E a * E (- a) = 1" | |
| 2610 | by (simp ) | |
| 2611 | have th1: "E a $ 0 \<noteq> 0" by simp | |
| 2612 | from fps_inverse_unique[OF th1 th0] show ?thesis by simp | |
| 2613 | qed | |
| 2614 | ||
| 31273 | 2615 | lemma E_nth_deriv[simp]: "fps_nth_deriv n (E (a::'a::field_char_0)) = (fps_const a)^n * (E a)" | 
| 48757 | 2616 | by (induct n) (auto simp add: power_Suc) | 
| 29687 | 2617 | |
| 31021 | 2618 | lemma X_compose_E[simp]: "X oo E (a::'a::{field}) = E a - 1"
 | 
| 29687 | 2619 | by (simp add: fps_eq_iff X_fps_compose) | 
| 2620 | ||
| 30488 | 2621 | lemma LE_compose: | 
| 2622 | assumes a: "a\<noteq>0" | |
| 29687 | 2623 | shows "fps_inv (E a - 1) oo (E a - 1) = X" | 
| 2624 | and "(E a - 1) oo fps_inv (E a - 1) = X" | |
| 2625 | proof- | |
| 2626 | let ?b = "E a - 1" | |
| 2627 | have b0: "?b $ 0 = 0" by simp | |
| 2628 | have b1: "?b $ 1 \<noteq> 0" by (simp add: a) | |
| 2629 | from fps_inv[OF b0 b1] show "fps_inv (E a - 1) oo (E a - 1) = X" . | |
| 2630 | from fps_inv_right[OF b0 b1] show "(E a - 1) oo fps_inv (E a - 1) = X" . | |
| 2631 | qed | |
| 2632 | ||
| 2633 | ||
| 30488 | 2634 | lemma fps_const_inverse: | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2635 | "a \<noteq> 0 \<Longrightarrow> inverse (fps_const (a::'a::field)) = fps_const (inverse a)" | 
| 29687 | 2636 | apply (auto simp add: fps_eq_iff fps_inverse_def) by (case_tac "n", auto) | 
| 2637 | ||
| 30488 | 2638 | lemma inverse_one_plus_X: | 
| 31021 | 2639 |   "inverse (1 + X) = Abs_fps (\<lambda>n. (- 1 ::'a::{field})^n)"
 | 
| 29687 | 2640 | (is "inverse ?l = ?r") | 
| 2641 | proof- | |
| 2642 | have th: "?l * ?r = 1" | |
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 2643 | by (auto simp add: field_simps fps_eq_iff minus_one_power_iff simp del: minus_one) | 
| 29687 | 2644 | have th': "?l $ 0 \<noteq> 0" by (simp add: ) | 
| 2645 | from fps_inverse_unique[OF th' th] show ?thesis . | |
| 2646 | qed | |
| 2647 | ||
| 31273 | 2648 | lemma E_power_mult: "(E (c::'a::field_char_0))^n = E (of_nat n * c)" | 
| 48757 | 2649 | by (induct n) (auto simp add: field_simps E_add_mult power_Suc) | 
| 29687 | 2650 | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2651 | lemma radical_E: | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2652 | assumes r: "r (Suc k) 1 = 1" | 
| 31370 | 2653 |   shows "fps_radical r (Suc k) (E (c::'a::{field_char_0})) = E (c / of_nat (Suc k))"
 | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2654 | proof- | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2655 | let ?ck = "(c / of_nat (Suc k))" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2656 | let ?r = "fps_radical r (Suc k)" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2657 | 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 | 2658 | by (simp_all del: of_nat_Suc) | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2659 | 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 | 2660 | 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 | 2661 | "r (Suc k) (E c $ 0) = E ?ck $ 0" "E c $ 0 \<noteq> 0" using r by simp_all | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2662 | from th0 radical_unique[where r=r and k=k, OF th] | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2663 | show ?thesis by auto | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2664 | qed | 
| 29687 | 2665 | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2666 | lemma Ec_E1_eq: | 
| 31370 | 2667 |   "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 | 2668 | apply (auto simp add: fps_eq_iff E_def fps_compose_def power_mult_distrib) | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2669 | by (simp add: cond_value_iff cond_application_beta setsum_delta' cong del: if_weak_cong) | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2670 | |
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2671 | text{* The generalized binomial theorem as a  consequence of @{thm E_add_mult} *}
 | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2672 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2673 | lemma gbinomial_theorem: | 
| 36409 | 2674 |   "((a::'a::{field_char_0, field_inverse_zero})+b) ^ n = (\<Sum>k=0..n. of_nat (n choose k) * a^k * b^(n-k))"
 | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2675 | proof- | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2676 | from E_add_mult[of a b] | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2677 | have "(E (a + b)) $ n = (E a * E b)$n" by simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2678 | then have "(a + b) ^ n = (\<Sum>i\<Colon>nat = 0\<Colon>nat..n. a ^ i * b ^ (n - i) * (of_nat (fact n) / of_nat (fact i * fact (n - i))))" | 
| 36350 | 2679 | by (simp add: field_simps fps_mult_nth of_nat_mult[symmetric] setsum_right_distrib) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2680 | then show ?thesis | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2681 | apply simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2682 | apply (rule setsum_cong2) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2683 | apply simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2684 | apply (frule binomial_fact[where ?'a = 'a, symmetric]) | 
| 36350 | 2685 | by (simp add: field_simps of_nat_mult) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2686 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2687 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2688 | text{* And the nat-form -- also available from Binomial.thy *}
 | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2689 | lemma binomial_theorem: "(a+b) ^ n = (\<Sum>k=0..n. (n choose k) * a^k * b^(n-k))" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2690 | using gbinomial_theorem[of "of_nat a" "of_nat b" n] | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2691 | unfolding of_nat_add[symmetric] of_nat_power[symmetric] of_nat_mult[symmetric] of_nat_setsum[symmetric] | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2692 | by simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2693 | |
| 30488 | 2694 | subsubsection{* Logarithmic series *}
 | 
| 29687 | 2695 | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2696 | lemma Abs_fps_if_0: | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2697 | "Abs_fps(%n. if n=0 then (v::'a::ring_1) else f n) = fps_const v + X * Abs_fps (%n. f (Suc n))" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2698 | by (auto simp add: fps_eq_iff) | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2699 | |
| 31370 | 2700 | definition L:: "'a::{field_char_0} \<Rightarrow> 'a fps" where 
 | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2701 | "L c \<equiv> fps_const (1/c) * Abs_fps (\<lambda>n. if n = 0 then 0 else (- 1) ^ (n - 1) / of_nat n)" | 
| 29687 | 2702 | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2703 | lemma fps_deriv_L: "fps_deriv (L c) = fps_const (1/c) * inverse (1 + X)" | 
| 29687 | 2704 | unfolding inverse_one_plus_X | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2705 | by (simp add: L_def fps_eq_iff del: of_nat_Suc) | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2706 | |
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2707 | lemma L_nth: "L c $ n = (if n=0 then 0 else 1/c * ((- 1) ^ (n - 1) / of_nat n))" | 
| 36350 | 2708 | by (simp add: L_def field_simps) | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2709 | |
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2710 | lemma L_0[simp]: "L c $ 0 = 0" by (simp add: L_def) | 
| 29687 | 2711 | lemma L_E_inv: | 
| 31370 | 2712 |   assumes a: "a\<noteq> (0::'a::{field_char_0})"
 | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2713 | shows "L a = fps_inv (E a - 1)" (is "?l = ?r") | 
| 29687 | 2714 | proof- | 
| 2715 | let ?b = "E a - 1" | |
| 2716 | have b0: "?b $ 0 = 0" by simp | |
| 2717 | have b1: "?b $ 1 \<noteq> 0" by (simp add: a) | |
| 2718 | have "fps_deriv (E a - 1) oo fps_inv (E a - 1) = (fps_const a * (E a - 1) + fps_const a) oo fps_inv (E a - 1)" | |
| 36350 | 2719 | by (simp add: field_simps) | 
| 29687 | 2720 | also have "\<dots> = fps_const a * (X + 1)" apply (simp add: fps_compose_add_distrib fps_const_mult_apply_left[symmetric] fps_inv_right[OF b0 b1]) | 
| 36350 | 2721 | by (simp add: field_simps) | 
| 29687 | 2722 | finally have eq: "fps_deriv (E a - 1) oo fps_inv (E a - 1) = fps_const a * (X + 1)" . | 
| 2723 | from fps_inv_deriv[OF b0 b1, unfolded eq] | |
| 2724 | have "fps_deriv (fps_inv ?b) = fps_const (inverse a) / (X + 1)" | |
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2725 | using a | 
| 29687 | 2726 | by (simp add: fps_const_inverse eq fps_divide_def fps_inverse_mult) | 
| 30488 | 2727 | hence "fps_deriv ?l = fps_deriv ?r" | 
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2728 | by (simp add: fps_deriv_L add_commute fps_divide_def divide_inverse) | 
| 29687 | 2729 | then show ?thesis unfolding fps_deriv_eq_iff | 
| 2730 | by (simp add: L_nth fps_inv_def) | |
| 2731 | qed | |
| 2732 | ||
| 31369 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2733 | lemma L_mult_add: | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2734 | assumes c0: "c\<noteq>0" and d0: "d\<noteq>0" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2735 | shows "L c + L d = fps_const (c+d) * L (c*d)" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2736 | (is "?r = ?l") | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2737 | proof- | 
| 36350 | 2738 | 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 | 2739 | 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 | 2740 | 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 | 2741 | also have "\<dots> = fps_deriv ?l" | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2742 | apply (simp add: fps_deriv_L) | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2743 | by (simp add: fps_eq_iff eq) | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2744 | finally show ?thesis | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2745 | unfolding fps_deriv_eq_iff by simp | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2746 | qed | 
| 
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
 chaieb parents: 
31199diff
changeset | 2747 | |
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2748 | subsubsection{* Binomial series *}
 | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2749 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2750 | 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 | 2751 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2752 | 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 | 2753 | by (simp add: fps_binomial_def) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2754 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2755 | lemma fps_binomial_ODE_unique: | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2756 | fixes c :: "'a::field_char_0" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2757 | 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 | 2758 | (is "?lhs \<longleftrightarrow> ?rhs") | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2759 | proof- | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2760 | let ?da = "fps_deriv a" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2761 | let ?x1 = "(1 + X):: 'a fps" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2762 | let ?l = "?x1 * ?da" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2763 | let ?r = "fps_const c * a" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2764 | have x10: "?x1 $ 0 \<noteq> 0" by simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2765 | have "?l = ?r \<longleftrightarrow> inverse ?x1 * ?l = inverse ?x1 * ?r" by simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2766 | also have "\<dots> \<longleftrightarrow> ?da = (fps_const c * a) / ?x1" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2767 | apply (simp only: fps_divide_def mult_assoc[symmetric] inverse_mult_eq_1[OF x10]) | 
| 36350 | 2768 | by (simp add: field_simps) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2769 | finally have eq: "?l = ?r \<longleftrightarrow> ?lhs" by simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2770 | moreover | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2771 |   {assume h: "?l = ?r" 
 | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2772 |     {fix n
 | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2773 | from h have lrn: "?l $ n = ?r$n" by simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2774 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2775 | from lrn | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2776 | have "a$ Suc n = ((c - of_nat n) / of_nat (Suc n)) * a $n" | 
| 36350 | 2777 | apply (simp add: field_simps del: of_nat_Suc) | 
| 2778 | by (cases n, simp_all add: field_simps del: of_nat_Suc) | |
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2779 | } | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2780 | note th0 = this | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2781 |     {fix n have "a$n = (c gchoose n) * a$0"
 | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2782 | proof(induct n) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2783 | case 0 thus ?case by simp | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2784 | next | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2785 | case (Suc m) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2786 | thus ?case unfolding th0 | 
| 36350 | 2787 | apply (simp add: field_simps del: of_nat_Suc) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2788 | unfolding mult_assoc[symmetric] gbinomial_mult_1 | 
| 36350 | 2789 | by (simp add: field_simps) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2790 | qed} | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2791 | note th1 = this | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2792 | have ?rhs | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2793 | apply (simp add: fps_eq_iff) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2794 | apply (subst th1) | 
| 36350 | 2795 | by (simp add: field_simps)} | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2796 | moreover | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2797 |   {assume h: ?rhs
 | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2798 | have th00:"\<And>x y. x * (a$0 * y) = a$0 * (x*y)" by (simp add: mult_commute) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2799 | have "?l = ?r" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2800 | apply (subst h) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2801 | apply (subst (2) h) | 
| 36350 | 2802 | apply (clarsimp simp add: fps_eq_iff field_simps) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2803 | unfolding mult_assoc[symmetric] th00 gbinomial_mult_1 | 
| 36350 | 2804 | by (simp add: field_simps gbinomial_mult_1)} | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2805 | ultimately show ?thesis by blast | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2806 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2807 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2808 | lemma fps_binomial_deriv: "fps_deriv (fps_binomial c) = fps_const c * fps_binomial c / (1 + X)" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2809 | proof- | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2810 | let ?a = "fps_binomial c" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2811 | 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 | 2812 | 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 | 2813 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2814 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2815 | lemma fps_binomial_add_mult: "fps_binomial (c+d) = fps_binomial c * fps_binomial d" (is "?l = ?r") | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2816 | proof- | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2817 | let ?P = "?r - ?l" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2818 | let ?b = "fps_binomial" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2819 | let ?db = "\<lambda>x. fps_deriv (?b x)" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2820 | have "fps_deriv ?P = ?db c * ?b d + ?b c * ?db d - ?db (c + d)" by simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2821 | also have "\<dots> = inverse (1 + X) * (fps_const c * ?b c * ?b d + fps_const d * ?b c * ?b d - fps_const (c+d) * ?b (c + d))" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2822 | unfolding fps_binomial_deriv | 
| 36350 | 2823 | 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 | 2824 | also have "\<dots> = (fps_const (c + d)/ (1 + X)) * ?P" | 
| 36350 | 2825 | by (simp add: field_simps fps_divide_def 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 | 2826 | 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 | 2827 | by (simp add: fps_divide_def) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2828 | 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 | 2829 | unfolding fps_binomial_ODE_unique[symmetric] | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2830 | using th0 by simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2831 | hence "?P = 0" by (simp add: fps_mult_nth) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2832 | then show ?thesis by simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2833 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2834 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2835 | lemma fps_minomial_minus_one: "fps_binomial (- 1) = inverse (1 + X)" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2836 | (is "?l = inverse ?r") | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2837 | proof- | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2838 | have th: "?r$0 \<noteq> 0" by simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2839 | have th': "fps_deriv (inverse ?r) = fps_const (- 1) * inverse ?r / (1 + X)" | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 2840 | by (simp add: fps_inverse_deriv[OF th] fps_divide_def power2_eq_square mult_commute fps_const_neg[symmetric] del: fps_const_neg minus_one) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2841 | have eq: "inverse ?r $ 0 = 1" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2842 | by (simp add: fps_inverse_def) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2843 | 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 | 2844 | show ?thesis by (simp add: fps_inverse_def) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2845 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2846 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2847 | text{* Vandermonde's Identity as a consequence *}
 | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2848 | lemma gbinomial_Vandermonde: "setsum (\<lambda>k. (a gchoose k) * (b gchoose (n - k))) {0..n} = (a + b) gchoose n"
 | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2849 | proof- | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2850 | let ?ba = "fps_binomial a" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2851 | let ?bb = "fps_binomial b" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2852 | let ?bab = "fps_binomial (a + b)" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2853 | 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 | 2854 | 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 | 2855 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2856 | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2857 | lemma binomial_Vandermonde: "setsum (\<lambda>k. (a choose k) * (b choose (n - k))) {0..n} = (a + b) choose n"
 | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2858 | using gbinomial_Vandermonde[of "(of_nat a)" "of_nat b" n] | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2859 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2860 | apply (simp only: binomial_gbinomial[symmetric] of_nat_mult[symmetric] of_nat_setsum[symmetric] of_nat_add[symmetric]) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2861 | by simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2862 | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2863 | lemma binomial_Vandermonde_same: "setsum (\<lambda>k. (n choose k)^2) {0..n} = (2*n) choose n"
 | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2864 | using binomial_Vandermonde[of n n n,symmetric] | 
| 47217 
501b9bbd0d6e
removed redundant nat-specific copies of theorems
 huffman parents: 
47108diff
changeset | 2865 | unfolding mult_2 apply (simp add: power2_eq_square) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2866 | apply (rule setsum_cong2) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2867 | by (auto intro: binomial_symmetric) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 2868 | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2869 | lemma Vandermonde_pochhammer_lemma: | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2870 | fixes a :: "'a::field_char_0" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2871 |   assumes b: "\<forall> j\<in>{0 ..<n}. b \<noteq> of_nat j"
 | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2872 |   shows "setsum (%k. (pochhammer (- a) k * pochhammer (- (of_nat n)) k) / (of_nat (fact k) * pochhammer (b - of_nat n + 1) k)) {0..n} = pochhammer (- (a+ b)) n / pochhammer (- b) n" (is "?l = ?r")
 | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2873 | proof- | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2874 | let ?m1 = "%m. (- 1 :: 'a) ^ m" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2875 | let ?f = "%m. of_nat (fact m)" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2876 | let ?p = "%(x::'a). pochhammer (- x)" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2877 | from b have bn0: "?p b n \<noteq> 0" unfolding pochhammer_eq_0_iff by simp | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2878 |   {fix k assume kn: "k \<in> {0..n}"
 | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2879 |     {assume c:"pochhammer (b - of_nat n + 1) n = 0"
 | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2880 | 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 | 2881 | unfolding pochhammer_eq_0_iff by blast | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2882 | 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 | 2883 | by (simp add: algebra_simps) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2884 | 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 | 2885 | using j kn by (simp add: of_nat_diff) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2886 | with b have False using j by auto} | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2887 | then have nz: "pochhammer (1 + b - of_nat n) n \<noteq> 0" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2888 | by (auto simp add: algebra_simps) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2889 | |
| 35175 | 2890 | from nz kn [simplified] have nz': "pochhammer (1 + b - of_nat n) k \<noteq> 0" | 
| 2891 | by (rule pochhammer_neq_0_mono) | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2892 |     {assume k0: "k = 0 \<or> n =0" 
 | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2893 | then have "b gchoose (n - k) = (?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f 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 | 2894 | using kn | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2895 | by (cases "k=0", simp_all add: gbinomial_pochhammer)} | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2896 | moreover | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2897 |     {assume n0: "n \<noteq> 0" and k0: "k \<noteq> 0" 
 | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2898 | then obtain m where m: "n = Suc m" by (cases n, auto) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2899 | from k0 obtain h where h: "k = Suc h" by (cases k, auto) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2900 |       {assume kn: "k = n"
 | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2901 | then have "b gchoose (n - k) = (?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k)" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2902 | using kn pochhammer_minus'[where k=k and n=n and b=b] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2903 | apply (simp add: pochhammer_same) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2904 | using bn0 | 
| 36350 | 2905 | by (simp add: field_simps power_add[symmetric])} | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2906 | moreover | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2907 |       {assume nk: "k \<noteq> n"
 | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2908 |         have m1nk: "?m1 n = setprod (%i. - 1) {0..m}" 
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2909 |           "?m1 k = setprod (%i. - 1) {0..h}"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2910 | by (simp_all add: setprod_constant m h) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2911 | from kn nk have kn': "k < n" by simp | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2912 | have bnz0: "pochhammer (b - of_nat n + 1) k \<noteq> 0" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2913 | using bn0 kn | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2914 | unfolding pochhammer_eq_0_iff | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2915 | apply auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2916 | apply (erule_tac x= "n - ka - 1" in allE) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2917 | by (auto simp add: algebra_simps of_nat_diff) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2918 |         have eq1: "setprod (%k. (1::'a) + of_nat m - of_nat k) {0 .. h} = setprod of_nat {Suc (m - h) .. Suc m}"        
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2919 | apply (rule strong_setprod_reindex_cong[where f="%k. Suc m - k "]) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2920 | using kn' h m | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2921 | apply (auto simp add: inj_on_def image_def) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2922 | apply (rule_tac x="Suc m - x" in bexI) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2923 | apply (simp_all add: of_nat_diff) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2924 | done | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2925 | |
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2926 | have th1: "(?m1 k * ?p (of_nat n) k) / ?f n = 1 / of_nat(fact (n - k))" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2927 | unfolding m1nk | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2928 | |
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2929 | unfolding m h pochhammer_Suc_setprod | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 2930 | apply (simp add: field_simps del: fact_Suc id_def minus_one) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2931 | unfolding fact_altdef_nat id_def | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2932 | unfolding of_nat_setprod | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2933 | unfolding setprod_timesf[symmetric] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2934 | apply auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2935 | unfolding eq1 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2936 | apply (subst setprod_Un_disjoint[symmetric]) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2937 | apply (auto) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2938 | apply (rule setprod_cong) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2939 | apply auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2940 | done | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2941 |         have th20: "?m1 n * ?p b n = setprod (%i. b - of_nat i) {0..m}"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2942 | unfolding m1nk | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2943 | unfolding m h pochhammer_Suc_setprod | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2944 | unfolding setprod_timesf[symmetric] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2945 | apply (rule setprod_cong) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2946 | apply auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2947 | done | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2948 |         have th21:"pochhammer (b - of_nat n + 1) k = setprod (%i. b - of_nat i) {n - k .. n - 1}"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2949 | unfolding h m | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2950 | unfolding pochhammer_Suc_setprod | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2951 | apply (rule strong_setprod_reindex_cong[where f="%k. n - 1 - k"]) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2952 | using kn | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2953 | apply (auto simp add: inj_on_def m h image_def) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2954 | apply (rule_tac x= "m - x" in bexI) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2955 | by (auto simp add: of_nat_diff) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2956 | |
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2957 |         have "?m1 n * ?p b n = pochhammer (b - of_nat n + 1) k * setprod (%i. b - of_nat i) {0.. n - k - 1}"
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2958 | unfolding th20 th21 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2959 | unfolding h m | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2960 | apply (subst setprod_Un_disjoint[symmetric]) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2961 | using kn' h m | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2962 | apply auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2963 | apply (rule setprod_cong) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2964 | apply auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2965 | done | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2966 |         then have th2: "(?m1 n * ?p b n)/pochhammer (b - of_nat n + 1) k = setprod (%i. b - of_nat i) {0.. n - k - 1}" 
 | 
| 36350 | 2967 | using nz' by (simp add: field_simps) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2968 | have "(?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k) = ((?m1 k * ?p (of_nat n) k) / ?f n) * ((?m1 n * ?p b n)/pochhammer (b - of_nat n + 1) k)" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2969 | using bnz0 | 
| 36350 | 2970 | by (simp add: field_simps) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2971 | also have "\<dots> = b gchoose (n - k)" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2972 | unfolding th1 th2 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2973 | using kn' by (simp add: gbinomial_def) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 2974 | finally have "b gchoose (n - k) = (?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k)" by simp} | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2975 | ultimately have "b gchoose (n - k) = (?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f 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 | 2976 | by (cases "k =n", auto)} | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2977 | ultimately have "b gchoose (n - k) = (?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k)" "pochhammer (1 + b - of_nat n) k \<noteq> 0 " | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2978 | using nz' | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2979 | apply (cases "n=0", auto) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2980 | by (cases "k", auto)} | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2981 | note th00 = this | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2982 | have "?r = ((a + b) gchoose n) * (of_nat (fact n)/ (?m1 n * pochhammer (- b) n))" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2983 | unfolding gbinomial_pochhammer | 
| 36350 | 2984 | using bn0 by (auto simp add: field_simps) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2985 | also have "\<dots> = ?l" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2986 | unfolding gbinomial_Vandermonde[symmetric] | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2987 | apply (simp add: th00) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2988 | unfolding gbinomial_pochhammer | 
| 36350 | 2989 | using bn0 apply (simp add: setsum_left_distrib setsum_right_distrib field_simps) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2990 | apply (rule setsum_cong2) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2991 | apply (drule th00(2)) | 
| 36350 | 2992 | by (simp add: field_simps power_add[symmetric]) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2993 | finally show ?thesis by simp | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2994 | qed | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2995 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2996 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2997 | lemma Vandermonde_pochhammer: | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2998 | fixes a :: "'a::field_char_0" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 2999 |   assumes c: "ALL i : {0..< n}. c \<noteq> - of_nat i"
 | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3000 |   shows "setsum (%k. (pochhammer a k * pochhammer (- (of_nat n)) k) / (of_nat (fact k) * pochhammer c k)) {0..n} = pochhammer (c - a) n / pochhammer c n"
 | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3001 | proof- | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3002 | let ?a = "- a" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3003 | let ?b = "c + of_nat n - 1" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3004 |   have h: "\<forall> j \<in>{0..< n}. ?b \<noteq> of_nat j" using c
 | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3005 | apply (auto simp add: algebra_simps of_nat_diff) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3006 | apply (erule_tac x= "n - j - 1" in ballE) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3007 | by (auto simp add: of_nat_diff algebra_simps) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3008 | have th0: "pochhammer (- (?a + ?b)) n = (- 1)^n * pochhammer (c - a) n" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3009 | unfolding pochhammer_minus[OF le_refl] | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3010 | by (simp add: algebra_simps) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3011 | have th1: "pochhammer (- ?b) n = (- 1)^n * pochhammer c n" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3012 | unfolding pochhammer_minus[OF le_refl] | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3013 | by simp | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3014 | have nz: "pochhammer c n \<noteq> 0" using c | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3015 | by (simp add: pochhammer_eq_0_iff) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3016 | from Vandermonde_pochhammer_lemma[where a = "?a" and b="?b" and n=n, OF h, unfolded th0 th1] | 
| 36350 | 3017 | show ?thesis using nz by (simp add: field_simps setsum_right_distrib) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3018 | qed | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3019 | |
| 29906 | 3020 | subsubsection{* Formal trigonometric functions  *}
 | 
| 29687 | 3021 | |
| 31273 | 3022 | definition "fps_sin (c::'a::field_char_0) = | 
| 29687 | 3023 | Abs_fps (\<lambda>n. if even n then 0 else (- 1) ^((n - 1) div 2) * c^n /(of_nat (fact n)))" | 
| 3024 | ||
| 31273 | 3025 | definition "fps_cos (c::'a::field_char_0) = | 
| 3026 | Abs_fps (\<lambda>n. if even n then (- 1) ^ (n div 2) * c^n / (of_nat (fact n)) else 0)" | |
| 29687 | 3027 | |
| 30488 | 3028 | lemma fps_sin_deriv: | 
| 29687 | 3029 | "fps_deriv (fps_sin c) = fps_const c * fps_cos c" | 
| 3030 | (is "?lhs = ?rhs") | |
| 31273 | 3031 | proof (rule fps_ext) | 
| 3032 | fix n::nat | |
| 29687 | 3033 |     {assume en: "even n"
 | 
| 3034 | have "?lhs$n = of_nat (n+1) * (fps_sin c $ (n+1))" by simp | |
| 30488 | 3035 | also have "\<dots> = of_nat (n+1) * ((- 1)^(n div 2) * c^Suc n / of_nat (fact (Suc n)))" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 3036 | using en by (simp add: fps_sin_def) | 
| 29687 | 3037 | also have "\<dots> = (- 1)^(n div 2) * c^Suc n * (of_nat (n+1) / (of_nat (Suc n) * of_nat (fact n)))" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 3038 | unfolding fact_Suc of_nat_mult | 
| 36350 | 3039 | by (simp add: field_simps del: of_nat_add of_nat_Suc) | 
| 29687 | 3040 | also have "\<dots> = (- 1)^(n div 2) *c^Suc n / of_nat (fact n)" | 
| 36350 | 3041 | by (simp add: field_simps del: of_nat_add of_nat_Suc) | 
| 30488 | 3042 | finally have "?lhs $n = ?rhs$n" using en | 
| 36350 | 3043 | by (simp add: fps_cos_def field_simps power_Suc )} | 
| 31273 | 3044 | then show "?lhs $ n = ?rhs $ n" | 
| 3045 | by (cases "even n", simp_all add: fps_deriv_def fps_sin_def fps_cos_def) | |
| 29687 | 3046 | qed | 
| 3047 | ||
| 30488 | 3048 | lemma fps_cos_deriv: | 
| 29687 | 3049 | "fps_deriv (fps_cos c) = fps_const (- c)* (fps_sin c)" | 
| 3050 | (is "?lhs = ?rhs") | |
| 31273 | 3051 | proof (rule fps_ext) | 
| 29687 | 3052 | have th0: "\<And>n. - ((- 1::'a) ^ n) = (- 1)^Suc n" by (simp add: power_Suc) | 
| 31273 | 3053 | have th1: "\<And>n. odd n \<Longrightarrow> Suc ((n - 1) div 2) = Suc n div 2" | 
| 3054 | by (case_tac n, simp_all) | |
| 3055 | fix n::nat | |
| 29687 | 3056 |     {assume en: "odd n"
 | 
| 3057 | from en have n0: "n \<noteq>0 " by presburger | |
| 3058 | have "?lhs$n = of_nat (n+1) * (fps_cos c $ (n+1))" by simp | |
| 30488 | 3059 | also have "\<dots> = of_nat (n+1) * ((- 1)^((n + 1) div 2) * c^Suc n / of_nat (fact (Suc n)))" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 3060 | using en by (simp add: fps_cos_def) | 
| 29687 | 3061 | also have "\<dots> = (- 1)^((n + 1) div 2)*c^Suc n * (of_nat (n+1) / (of_nat (Suc n) * of_nat (fact n)))" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 3062 | unfolding fact_Suc of_nat_mult | 
| 36350 | 3063 | by (simp add: field_simps del: of_nat_add of_nat_Suc) | 
| 29687 | 3064 | also have "\<dots> = (- 1)^((n + 1) div 2) * c^Suc n / of_nat (fact n)" | 
| 36350 | 3065 | by (simp add: field_simps del: of_nat_add of_nat_Suc) | 
| 29687 | 3066 | also have "\<dots> = (- ((- 1)^((n - 1) div 2))) * c^Suc n / of_nat (fact n)" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 3067 | unfolding th0 unfolding th1[OF en] by simp | 
| 30488 | 3068 | finally have "?lhs $n = ?rhs$n" using en | 
| 36350 | 3069 | by (simp add: fps_sin_def field_simps power_Suc)} | 
| 31273 | 3070 | then show "?lhs $ n = ?rhs $ n" | 
| 30488 | 3071 | by (cases "even n", simp_all add: fps_deriv_def fps_sin_def | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 3072 | fps_cos_def) | 
| 29687 | 3073 | qed | 
| 3074 | ||
| 3075 | lemma fps_sin_cos_sum_of_squares: | |
| 3076 | "fps_cos c ^ 2 + fps_sin c ^ 2 = 1" (is "?lhs = 1") | |
| 3077 | proof- | |
| 3078 | have "fps_deriv ?lhs = 0" | |
| 3079 | apply (simp add: fps_deriv_power fps_sin_deriv fps_cos_deriv power_Suc) | |
| 36350 | 3080 | by (simp add: field_simps fps_const_neg[symmetric] del: fps_const_neg) | 
| 29687 | 3081 | then have "?lhs = fps_const (?lhs $ 0)" | 
| 3082 | unfolding fps_deriv_eq_0_iff . | |
| 3083 | also have "\<dots> = 1" | |
| 30960 | 3084 | by (auto simp add: fps_eq_iff numeral_2_eq_2 fps_mult_nth fps_cos_def fps_sin_def) | 
| 29687 | 3085 | finally show ?thesis . | 
| 3086 | qed | |
| 3087 | ||
| 31274 | 3088 | lemma divide_eq_iff: "a \<noteq> (0::'a::field) \<Longrightarrow> x / a = y \<longleftrightarrow> x = y * a" | 
| 3089 | by auto | |
| 3090 | ||
| 3091 | lemma eq_divide_iff: "a \<noteq> (0::'a::field) \<Longrightarrow> x = y / a \<longleftrightarrow> x * a = y" | |
| 3092 | by auto | |
| 3093 | ||
| 3094 | lemma fps_sin_nth_0 [simp]: "fps_sin c $ 0 = 0" | |
| 3095 | unfolding fps_sin_def by simp | |
| 3096 | ||
| 3097 | lemma fps_sin_nth_1 [simp]: "fps_sin c $ 1 = c" | |
| 3098 | unfolding fps_sin_def by simp | |
| 3099 | ||
| 3100 | lemma fps_sin_nth_add_2: | |
| 3101 | "fps_sin c $ (n + 2) = - (c * c * fps_sin c $ n / (of_nat(n+1) * of_nat(n+2)))" | |
| 3102 | unfolding fps_sin_def | |
| 3103 | apply (cases n, simp) | |
| 3104 | apply (simp add: divide_eq_iff eq_divide_iff del: of_nat_Suc fact_Suc) | |
| 3105 | apply (simp add: of_nat_mult del: of_nat_Suc mult_Suc) | |
| 3106 | done | |
| 3107 | ||
| 3108 | lemma fps_cos_nth_0 [simp]: "fps_cos c $ 0 = 1" | |
| 3109 | unfolding fps_cos_def by simp | |
| 3110 | ||
| 3111 | lemma fps_cos_nth_1 [simp]: "fps_cos c $ 1 = 0" | |
| 3112 | unfolding fps_cos_def by simp | |
| 3113 | ||
| 3114 | lemma fps_cos_nth_add_2: | |
| 3115 | "fps_cos c $ (n + 2) = - (c * c * fps_cos c $ n / (of_nat(n+1) * of_nat(n+2)))" | |
| 3116 | unfolding fps_cos_def | |
| 3117 | apply (simp add: divide_eq_iff eq_divide_iff del: of_nat_Suc fact_Suc) | |
| 3118 | apply (simp add: of_nat_mult del: of_nat_Suc mult_Suc) | |
| 3119 | done | |
| 3120 | ||
| 3121 | lemma nat_induct2: | |
| 3122 | "\<lbrakk>P 0; P 1; \<And>n. P n \<Longrightarrow> P (n + 2)\<rbrakk> \<Longrightarrow> P (n::nat)" | |
| 3123 | unfolding One_nat_def numeral_2_eq_2 | |
| 3124 | apply (induct n rule: nat_less_induct) | |
| 3125 | apply (case_tac n, simp) | |
| 3126 | apply (rename_tac m, case_tac m, simp) | |
| 3127 | apply (rename_tac k, case_tac k, simp_all) | |
| 3128 | done | |
| 3129 | ||
| 3130 | lemma nat_add_1_add_1: "(n::nat) + 1 + 1 = n + 2" | |
| 3131 | by simp | |
| 3132 | ||
| 3133 | lemma eq_fps_sin: | |
| 3134 | assumes 0: "a $ 0 = 0" and 1: "a $ 1 = c" | |
| 3135 | and 2: "fps_deriv (fps_deriv a) = - (fps_const c * fps_const c * a)" | |
| 3136 | shows "a = fps_sin c" | |
| 3137 | apply (rule fps_ext) | |
| 3138 | apply (induct_tac n rule: nat_induct2) | |
| 3139 | apply (simp add: fps_sin_nth_0 0) | |
| 3140 | apply (simp add: fps_sin_nth_1 1 del: One_nat_def) | |
| 3141 | apply (rename_tac m, cut_tac f="\<lambda>a. a $ m" in arg_cong [OF 2]) | |
| 3142 | apply (simp add: nat_add_1_add_1 fps_sin_nth_add_2 | |
| 3143 | del: One_nat_def of_nat_Suc of_nat_add add_2_eq_Suc') | |
| 3144 | apply (subst minus_divide_left) | |
| 3145 | apply (subst eq_divide_iff) | |
| 3146 | apply (simp del: of_nat_add of_nat_Suc) | |
| 3147 | apply (simp only: mult_ac) | |
| 3148 | done | |
| 3149 | ||
| 3150 | lemma eq_fps_cos: | |
| 3151 | assumes 0: "a $ 0 = 1" and 1: "a $ 1 = 0" | |
| 3152 | and 2: "fps_deriv (fps_deriv a) = - (fps_const c * fps_const c * a)" | |
| 3153 | shows "a = fps_cos c" | |
| 3154 | apply (rule fps_ext) | |
| 3155 | apply (induct_tac n rule: nat_induct2) | |
| 3156 | apply (simp add: fps_cos_nth_0 0) | |
| 3157 | apply (simp add: fps_cos_nth_1 1 del: One_nat_def) | |
| 3158 | apply (rename_tac m, cut_tac f="\<lambda>a. a $ m" in arg_cong [OF 2]) | |
| 3159 | apply (simp add: nat_add_1_add_1 fps_cos_nth_add_2 | |
| 3160 | del: One_nat_def of_nat_Suc of_nat_add add_2_eq_Suc') | |
| 3161 | apply (subst minus_divide_left) | |
| 3162 | apply (subst eq_divide_iff) | |
| 3163 | apply (simp del: of_nat_add of_nat_Suc) | |
| 3164 | apply (simp only: mult_ac) | |
| 3165 | done | |
| 3166 | ||
| 3167 | lemma mult_nth_0 [simp]: "(a * b) $ 0 = a $ 0 * b $ 0" | |
| 3168 | by (simp add: fps_mult_nth) | |
| 3169 | ||
| 3170 | lemma mult_nth_1 [simp]: "(a * b) $ 1 = a $ 0 * b $ 1 + a $ 1 * b $ 0" | |
| 3171 | by (simp add: fps_mult_nth) | |
| 3172 | ||
| 3173 | lemma fps_sin_add: | |
| 3174 | "fps_sin (a + b) = fps_sin a * fps_cos b + fps_cos a * fps_sin b" | |
| 3175 | apply (rule eq_fps_sin [symmetric], simp, simp del: One_nat_def) | |
| 3176 | apply (simp del: fps_const_neg fps_const_add fps_const_mult | |
| 3177 | add: fps_const_add [symmetric] fps_const_neg [symmetric] | |
| 3178 | fps_sin_deriv fps_cos_deriv algebra_simps) | |
| 3179 | done | |
| 3180 | ||
| 3181 | lemma fps_cos_add: | |
| 3182 | "fps_cos (a + b) = fps_cos a * fps_cos b - fps_sin a * fps_sin b" | |
| 3183 | apply (rule eq_fps_cos [symmetric], simp, simp del: One_nat_def) | |
| 3184 | apply (simp del: fps_const_neg fps_const_add fps_const_mult | |
| 3185 | add: fps_const_add [symmetric] fps_const_neg [symmetric] | |
| 3186 | fps_sin_deriv fps_cos_deriv algebra_simps) | |
| 3187 | done | |
| 3188 | ||
| 31968 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 3189 | lemma fps_sin_even: "fps_sin (- c) = - fps_sin c" | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 3190 | by (auto simp add: fps_eq_iff fps_sin_def) | 
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 3191 | |
| 
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
 chaieb parents: 
31790diff
changeset | 3192 | 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 | 3193 | 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 | 3194 | |
| 29687 | 3195 | definition "fps_tan c = fps_sin c / fps_cos c" | 
| 3196 | ||
| 3197 | lemma fps_tan_deriv: "fps_deriv(fps_tan c) = fps_const c/ (fps_cos c ^ 2)" | |
| 3198 | proof- | |
| 3199 | have th0: "fps_cos c $ 0 \<noteq> 0" by (simp add: fps_cos_def) | |
| 30488 | 3200 | show ?thesis | 
| 29687 | 3201 | using fps_sin_cos_sum_of_squares[of c] | 
| 36350 | 3202 | apply (simp add: fps_tan_def fps_divide_deriv[OF th0] fps_sin_deriv fps_cos_deriv add: fps_const_neg[symmetric] field_simps power2_eq_square del: fps_const_neg) | 
| 29687 | 3203 | unfolding right_distrib[symmetric] | 
| 3204 | by simp | |
| 3205 | qed | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 3206 | |
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3207 | text {* Connection to E c over the complex numbers --- Euler and De Moivre*}
 | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3208 | lemma Eii_sin_cos: | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3209 | "E (ii * c) = fps_cos c + fps_const ii * fps_sin c " | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3210 | (is "?l = ?r") | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3211 | proof- | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3212 |   {fix n::nat
 | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3213 |     {assume en: "even n"
 | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3214 | from en obtain m where m: "n = 2*m" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 3215 | unfolding even_mult_two_ex by blast | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3216 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3217 | have "?l $n = ?r$n" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 3218 | by (simp add: m fps_sin_def fps_cos_def power_mult_distrib | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 3219 | power_mult power_minus)} | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3220 | moreover | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3221 |     {assume on: "odd n"
 | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3222 | from on obtain m where m: "n = 2*m + 1" | 
| 47217 
501b9bbd0d6e
removed redundant nat-specific copies of theorems
 huffman parents: 
47108diff
changeset | 3223 | unfolding odd_nat_equiv_def2 by (auto simp add: mult_2) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3224 | have "?l $n = ?r$n" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 3225 | by (simp add: m fps_sin_def fps_cos_def power_mult_distrib | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32456diff
changeset | 3226 | power_mult power_minus)} | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3227 | ultimately have "?l $n = ?r$n" by blast} | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3228 | then show ?thesis by (simp add: fps_eq_iff) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3229 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3230 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3231 | lemma E_minus_ii_sin_cos: "E (- (ii * c)) = fps_cos c - fps_const ii * fps_sin c " | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3232 | 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 | 3233 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3234 | lemma fps_const_minus: "fps_const (c::'a::group_add) - fps_const d = fps_const (c - d)" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3235 | by (simp add: fps_eq_iff fps_const_def) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3236 | |
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 3237 | lemma fps_numeral_fps_const: "numeral i = fps_const (numeral i :: 'a:: {comm_ring_1})"
 | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 3238 | by (fact numeral_fps_const) (* FIXME: duplicate *) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3239 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3240 | lemma fps_cos_Eii: | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3241 | "fps_cos c = (E (ii * c) + E (- ii * c)) / fps_const 2" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3242 | proof- | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3243 | 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 | 3244 | by (simp add: numeral_fps_const) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3245 | show ?thesis | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3246 | unfolding Eii_sin_cos minus_mult_commute | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 3247 | by (simp add: fps_sin_even fps_cos_odd numeral_fps_const | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 3248 | fps_divide_def fps_const_inverse th) | 
| 32157 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3249 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3250 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3251 | lemma fps_sin_Eii: | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3252 | "fps_sin c = (E (ii * c) - E (- ii * c)) / fps_const (2*ii)" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3253 | proof- | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3254 | have th: "fps_const \<i> * fps_sin c + fps_const \<i> * fps_sin c = fps_sin c * fps_const (2 * ii)" | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46757diff
changeset | 3255 | 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 | 3256 | show ?thesis | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3257 | unfolding Eii_sin_cos minus_mult_commute | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3258 | by (simp add: fps_sin_even fps_cos_odd fps_divide_def fps_const_inverse th) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3259 | qed | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3260 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3261 | lemma fps_tan_Eii: | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3262 | "fps_tan c = (E (ii * c) - E (- ii * c)) / (fps_const ii * (E (ii * c) + E (- ii * c)))" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3263 | unfolding fps_tan_def fps_sin_Eii fps_cos_Eii mult_minus_left E_neg | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3264 | apply (simp add: fps_divide_def fps_inverse_mult fps_const_mult[symmetric] fps_const_inverse del: fps_const_mult) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3265 | by simp | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3266 | |
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3267 | lemma fps_demoivre: "(fps_cos a + fps_const ii * fps_sin a)^n = fps_cos (of_nat n * a) + fps_const ii * fps_sin (of_nat n * a)" | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3268 | unfolding Eii_sin_cos[symmetric] E_power_mult | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3269 | by (simp add: mult_ac) | 
| 
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
 chaieb parents: 
31968diff
changeset | 3270 | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3271 | subsection {* Hypergeometric series *}
 | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3272 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3273 | |
| 36409 | 3274 | definition "F as bs (c::'a::{field_char_0, field_inverse_zero}) = Abs_fps (%n. (foldl (%r a. r* pochhammer a n) 1 as * c^n)/ (foldl (%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 | 3275 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3276 | lemma F_nth[simp]: "F as bs c $ n = (foldl (%r a. r* pochhammer a n) 1 as * c^n)/ (foldl (%r b. r * pochhammer b n) 1 bs * of_nat (fact n))" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3277 | by (simp add: F_def) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3278 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3279 | lemma foldl_mult_start: | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3280 | "foldl (%r x. r * f x) (v::'a::comm_ring_1) as * x = foldl (%r x. r * f x) (v * x) as " | 
| 48757 | 3281 | 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 | 3282 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3283 | lemma foldr_mult_foldl: "foldr (%x r. r * f x) as v = foldl (%r x. r * f x) (v :: 'a::comm_ring_1) as" | 
| 48757 | 3284 | 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 | 3285 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3286 | lemma F_nth_alt: "F as bs c $ n = foldr (\<lambda>a r. r * pochhammer a n) as (c ^ n) / | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3287 | 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 | 3288 | by (simp add: foldl_mult_start foldr_mult_foldl) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3289 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3290 | lemma F_E[simp]: "F [] [] c = E c" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3291 | by (simp add: fps_eq_iff) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3292 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3293 | lemma F_1_0[simp]: "F [1] [] c = 1/(1 - fps_const c * X)" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3294 | proof- | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3295 | 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 | 3296 | have th0: "(fps_const c * X) $ 0 = 0" by simp | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3297 | show ?thesis unfolding gp[OF th0, symmetric] | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3298 | by (auto simp add: fps_eq_iff pochhammer_fact[symmetric] fps_compose_nth power_mult_distrib cond_value_iff setsum_delta' cong del: if_weak_cong) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3299 | qed | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3300 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3301 | lemma F_B[simp]: "F [-a] [] (- 1) = fps_binomial a" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3302 | by (simp add: fps_eq_iff gbinomial_pochhammer algebra_simps) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3303 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3304 | lemma F_0[simp]: "F as bs c $0 = 1" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3305 | apply simp | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3306 | apply (subgoal_tac "ALL as. foldl (%(r::'a) (a::'a). r) 1 as = 1") | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3307 | apply auto | 
| 48757 | 3308 | apply (induct_tac as) | 
| 3309 | apply auto | |
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3310 | done | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3311 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3312 | lemma foldl_prod_prod: "foldl (%(r::'b::comm_ring_1) (x::'a::comm_ring_1). r * f x) v as * foldl (%r x. r * g x) w as = foldl (%r x. r * f x * g x) (v*w) as" | 
| 48757 | 3313 | 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 | 3314 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3315 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3316 | lemma F_rec: "F as bs c $ Suc n = ((foldl (%r a. r* (a + of_nat n)) c as)/ (foldl (%r b. r * (b + of_nat n)) (of_nat (Suc n)) bs )) * F as bs c $ n" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3317 | apply (simp del: of_nat_Suc of_nat_add fact_Suc) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3318 | 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 | 3319 | unfolding foldl_prod_prod[unfolded foldl_mult_start] pochhammer_Suc | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3320 | by (simp add: algebra_simps of_nat_mult) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3321 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3322 | lemma XD_nth[simp]: "XD a $ n = (if n=0 then 0 else of_nat n * a$n)" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3323 | by (simp add: XD_def) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3324 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3325 | lemma XD_0th[simp]: "XD a $ 0 = 0" by simp | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3326 | lemma XD_Suc[simp]:" XD a $ Suc n = of_nat (Suc n) * a $ Suc n" by simp | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3327 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3328 | definition "XDp c a = XD a + fps_const c * a" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3329 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3330 | 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 | 3331 | by (simp add: XDp_def algebra_simps) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3332 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3333 | lemma XDp_commute: | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3334 | shows "XDp b o XDp (c::'a::comm_ring_1) = XDp c o 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 | 3335 | 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 | 3336 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3337 | 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 | 3338 | by (simp add: fun_eq_iff fps_eq_iff) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3339 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3340 | lemma XDp_fps_integral[simp]:"XDp 0 (fps_integral a c) = X * a" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3341 | by (simp add: fps_eq_iff fps_integral_def) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3342 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3343 | lemma F_minus_nat: | 
| 36409 | 3344 |   "F [- of_nat n] [- of_nat (n + m)] (c::'a::{field_char_0, field_inverse_zero}) $ k = (if k <= n then pochhammer (- of_nat n) k * c ^ k /
 | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3345 | (pochhammer (- of_nat (n + m)) k * of_nat (fact k)) else 0)" | 
| 36409 | 3346 |   "F [- of_nat m] [- of_nat (m + n)] (c::'a::{field_char_0, field_inverse_zero}) $ k = (if k <= m then pochhammer (- of_nat m) k * c ^ k /
 | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3347 | (pochhammer (- of_nat (m + n)) k * of_nat (fact k)) else 0)" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3348 | by (auto simp add: pochhammer_eq_0_iff) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3349 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3350 | lemma setsum_eq_if: "setsum f {(n::nat) .. m} = (if m < n then 0 else f n + setsum f {n+1 .. m})"
 | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3351 | apply simp | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3352 | apply (subst setsum_insert[symmetric]) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3353 | by (auto simp add: not_less setsum_head_Suc) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3354 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3355 | lemma pochhammer_rec_if: | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3356 | "pochhammer a n = (if n = 0 then 1 else a * pochhammer (a + 1) (n - 1))" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3357 | by (cases n, simp_all add: pochhammer_rec) | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3358 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3359 | lemma XDp_foldr_nth[simp]: "foldr (%c r. XDp c o r) cs (%c. XDp c a) c0 $ n = | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3360 | foldr (%c r. (c + of_nat n) * r) cs (c0 + of_nat n) * a$n" | 
| 48757 | 3361 | by (induct cs arbitrary: c0) (auto simp add: algebra_simps) | 
| 32160 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3362 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3363 | lemma genric_XDp_foldr_nth: | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3364 | assumes | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3365 | f: "ALL n c a. f c a $ n = (of_nat n + k c) * a$n" | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3366 | |
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3367 | shows "foldr (%c r. f c o r) cs (%c. g c a) c0 $ n = | 
| 
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
 chaieb parents: 
32157diff
changeset | 3368 | foldr (%c r. (k c + of_nat n) * r) cs (g c0 a $ n)" | 
| 48757 | 3369 | 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 | 3370 | |
| 29911 
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
 huffman parents: 
29906diff
changeset | 3371 | end |