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